00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include "avutil.h"
00029 #include "avstring.h"
00030 #include "opt.h"
00031 #include "eval.h"
00032 #include "dict.h"
00033
00034 #if FF_API_FIND_OPT
00035
00036 const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags)
00037 {
00038 const AVOption *o = NULL;
00039
00040 while ((o = av_next_option(v, o))) {
00041 if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags)
00042 return o;
00043 }
00044 return NULL;
00045 }
00046 #endif
00047
00048 const AVOption *av_next_option(void *obj, const AVOption *last)
00049 {
00050 if (last && last[1].name) return ++last;
00051 else if (last || !(*(AVClass**)obj)->option->name) return NULL;
00052 else return (*(AVClass**)obj)->option;
00053 }
00054
00055 static int av_set_number2(void *obj, const char *name, double num, int den, int64_t intnum, const AVOption **o_out)
00056 {
00057 const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
00058 void *dst;
00059 if (o_out)
00060 *o_out= o;
00061 if (!o || o->offset<=0)
00062 return AVERROR_OPTION_NOT_FOUND;
00063
00064 if (o->max*den < num*intnum || o->min*den > num*intnum) {
00065 av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name);
00066 return AVERROR(ERANGE);
00067 }
00068
00069 dst= ((uint8_t*)obj) + o->offset;
00070
00071 switch (o->type) {
00072 case FF_OPT_TYPE_FLAGS:
00073 case FF_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break;
00074 case FF_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break;
00075 case FF_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break;
00076 case FF_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break;
00077 case FF_OPT_TYPE_RATIONAL:
00078 if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
00079 else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
00080 break;
00081 default:
00082 return AVERROR(EINVAL);
00083 }
00084 return 0;
00085 }
00086
00087 static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum)
00088 {
00089 const AVOption *o = NULL;
00090 if (av_set_number2(obj, name, num, den, intnum, &o) < 0)
00091 return NULL;
00092 else
00093 return o;
00094 }
00095
00096 static const double const_values[] = {
00097 M_PI,
00098 M_E,
00099 FF_QP2LAMBDA,
00100 0
00101 };
00102
00103 static const char * const const_names[] = {
00104 "PI",
00105 "E",
00106 "QP2LAMBDA",
00107 0
00108 };
00109
00110 static int hexchar2int(char c) {
00111 if (c >= '0' && c <= '9') return c - '0';
00112 if (c >= 'a' && c <= 'f') return c - 'a' + 10;
00113 if (c >= 'A' && c <= 'F') return c - 'A' + 10;
00114 return -1;
00115 }
00116
00117 int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)
00118 {
00119 int ret;
00120 const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
00121 if (o_out)
00122 *o_out = o;
00123 if (!o)
00124 return AVERROR_OPTION_NOT_FOUND;
00125 if ((!val && o->type != FF_OPT_TYPE_STRING) || o->offset<=0)
00126 return AVERROR(EINVAL);
00127
00128 if (o->type == FF_OPT_TYPE_BINARY) {
00129 uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset);
00130 int *lendst = (int *)(dst + 1);
00131 uint8_t *bin, *ptr;
00132 int len = strlen(val);
00133 av_freep(dst);
00134 *lendst = 0;
00135 if (len & 1) return AVERROR(EINVAL);
00136 len /= 2;
00137 ptr = bin = av_malloc(len);
00138 while (*val) {
00139 int a = hexchar2int(*val++);
00140 int b = hexchar2int(*val++);
00141 if (a < 0 || b < 0) {
00142 av_free(bin);
00143 return AVERROR(EINVAL);
00144 }
00145 *ptr++ = (a << 4) | b;
00146 }
00147 *dst = bin;
00148 *lendst = len;
00149 return 0;
00150 }
00151 if (o->type != FF_OPT_TYPE_STRING) {
00152 int notfirst=0;
00153 for (;;) {
00154 int i;
00155 char buf[256];
00156 int cmd=0;
00157 double d;
00158
00159 if (*val == '+' || *val == '-')
00160 cmd= *(val++);
00161
00162 for (i=0; i<sizeof(buf)-1 && val[i] && val[i]!='+' && val[i]!='-'; i++)
00163 buf[i]= val[i];
00164 buf[i]=0;
00165
00166 {
00167 const AVOption *o_named = av_opt_find(obj, buf, o->unit, 0, 0);
00168 if (o_named && o_named->type == FF_OPT_TYPE_CONST)
00169 d= o_named->default_val.dbl;
00170 else if (!strcmp(buf, "default")) d= o->default_val.dbl;
00171 else if (!strcmp(buf, "max" )) d= o->max;
00172 else if (!strcmp(buf, "min" )) d= o->min;
00173 else if (!strcmp(buf, "none" )) d= 0;
00174 else if (!strcmp(buf, "all" )) d= ~0;
00175 else {
00176 int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
00177 if (res < 0) {
00178 av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
00179 return res;
00180 }
00181 }
00182 }
00183 if (o->type == FF_OPT_TYPE_FLAGS) {
00184 if (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d;
00185 else if (cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d;
00186 } else {
00187 if (cmd=='+') d= notfirst*av_get_double(obj, name, NULL) + d;
00188 else if (cmd=='-') d= notfirst*av_get_double(obj, name, NULL) - d;
00189 }
00190
00191 if ((ret = av_set_number2(obj, name, d, 1, 1, o_out)) < 0)
00192 return ret;
00193 val+= i;
00194 if (!*val)
00195 return 0;
00196 notfirst=1;
00197 }
00198 return AVERROR(EINVAL);
00199 }
00200
00201 if (alloc) {
00202 av_free(*(void**)(((uint8_t*)obj) + o->offset));
00203 val= av_strdup(val);
00204 }
00205
00206 memcpy(((uint8_t*)obj) + o->offset, &val, sizeof(val));
00207 return 0;
00208 }
00209
00210 const AVOption *av_set_double(void *obj, const char *name, double n)
00211 {
00212 return av_set_number(obj, name, n, 1, 1);
00213 }
00214
00215 const AVOption *av_set_q(void *obj, const char *name, AVRational n)
00216 {
00217 return av_set_number(obj, name, n.num, n.den, 1);
00218 }
00219
00220 const AVOption *av_set_int(void *obj, const char *name, int64_t n)
00221 {
00222 return av_set_number(obj, name, 1, 1, n);
00223 }
00224
00230 const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len)
00231 {
00232 const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
00233 void *dst;
00234 uint8_t *bin;
00235 int len, i;
00236 if (!o || o->offset<=0)
00237 return NULL;
00238 if (o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
00239 return NULL;
00240
00241 dst= ((uint8_t*)obj) + o->offset;
00242 if (o_out) *o_out= o;
00243
00244 switch (o->type) {
00245 case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
00246 case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
00247 case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
00248 case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
00249 case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
00250 case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
00251 case FF_OPT_TYPE_STRING: return *(void**)dst;
00252 case FF_OPT_TYPE_BINARY:
00253 len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
00254 if (len >= (buf_len + 1)/2) return NULL;
00255 bin = *(uint8_t**)dst;
00256 for (i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]);
00257 break;
00258 default: return NULL;
00259 }
00260 return buf;
00261 }
00262
00263 static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum)
00264 {
00265 const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
00266 void *dst;
00267 if (!o || (o->offset<=0 && o->type != FF_OPT_TYPE_CONST))
00268 goto error;
00269
00270 dst= ((uint8_t*)obj) + o->offset;
00271
00272 if (o_out) *o_out= o;
00273
00274 switch (o->type) {
00275 case FF_OPT_TYPE_FLAGS: *intnum= *(unsigned int*)dst;return 0;
00276 case FF_OPT_TYPE_INT: *intnum= *(int *)dst;return 0;
00277 case FF_OPT_TYPE_INT64: *intnum= *(int64_t*)dst;return 0;
00278 case FF_OPT_TYPE_FLOAT: *num= *(float *)dst;return 0;
00279 case FF_OPT_TYPE_DOUBLE: *num= *(double *)dst;return 0;
00280 case FF_OPT_TYPE_RATIONAL: *intnum= ((AVRational*)dst)->num;
00281 *den = ((AVRational*)dst)->den;
00282 return 0;
00283 case FF_OPT_TYPE_CONST: *intnum= o->default_val.dbl;return 0;
00284 }
00285 error:
00286 *den=*intnum=0;
00287 return -1;
00288 }
00289
00290 double av_get_double(void *obj, const char *name, const AVOption **o_out)
00291 {
00292 int64_t intnum=1;
00293 double num=1;
00294 int den=1;
00295
00296 if (av_get_number(obj, name, o_out, &num, &den, &intnum) < 0)
00297 return NAN;
00298 return num*intnum/den;
00299 }
00300
00301 AVRational av_get_q(void *obj, const char *name, const AVOption **o_out)
00302 {
00303 int64_t intnum=1;
00304 double num=1;
00305 int den=1;
00306
00307 if (av_get_number(obj, name, o_out, &num, &den, &intnum) < 0)
00308 return (AVRational){0, 0};
00309 if (num == 1.0 && (int)intnum == intnum)
00310 return (AVRational){intnum, den};
00311 else
00312 return av_d2q(num*intnum/den, 1<<24);
00313 }
00314
00315 int64_t av_get_int(void *obj, const char *name, const AVOption **o_out)
00316 {
00317 int64_t intnum=1;
00318 double num=1;
00319 int den=1;
00320
00321 if (av_get_number(obj, name, o_out, &num, &den, &intnum) < 0)
00322 return -1;
00323 return num*intnum/den;
00324 }
00325
00326 int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
00327 {
00328 const AVOption *field = av_find_opt(obj, field_name, NULL, 0, 0);
00329 const AVOption *flag = av_find_opt(obj, flag_name, NULL, 0, 0);
00330
00331 if (!field || !flag || flag->type != FF_OPT_TYPE_CONST)
00332 return 0;
00333 return av_get_int(obj, field_name, NULL) & (int) flag->default_val.dbl;
00334 }
00335
00336 static void opt_list(void *obj, void *av_log_obj, const char *unit,
00337 int req_flags, int rej_flags)
00338 {
00339 const AVOption *opt=NULL;
00340
00341 while ((opt= av_next_option(obj, opt))) {
00342 if (!(opt->flags & req_flags) || (opt->flags & rej_flags))
00343 continue;
00344
00345
00346
00347
00348
00349 if (!unit && opt->type==FF_OPT_TYPE_CONST)
00350 continue;
00351 else if (unit && opt->type!=FF_OPT_TYPE_CONST)
00352 continue;
00353 else if (unit && opt->type==FF_OPT_TYPE_CONST && strcmp(unit, opt->unit))
00354 continue;
00355 else if (unit && opt->type == FF_OPT_TYPE_CONST)
00356 av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name);
00357 else
00358 av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name);
00359
00360 switch (opt->type) {
00361 case FF_OPT_TYPE_FLAGS:
00362 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<flags>");
00363 break;
00364 case FF_OPT_TYPE_INT:
00365 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int>");
00366 break;
00367 case FF_OPT_TYPE_INT64:
00368 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<int64>");
00369 break;
00370 case FF_OPT_TYPE_DOUBLE:
00371 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<double>");
00372 break;
00373 case FF_OPT_TYPE_FLOAT:
00374 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<float>");
00375 break;
00376 case FF_OPT_TYPE_STRING:
00377 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<string>");
00378 break;
00379 case FF_OPT_TYPE_RATIONAL:
00380 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<rational>");
00381 break;
00382 case FF_OPT_TYPE_BINARY:
00383 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "<binary>");
00384 break;
00385 case FF_OPT_TYPE_CONST:
00386 default:
00387 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "");
00388 break;
00389 }
00390 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
00391 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
00392 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM ) ? 'V' : '.');
00393 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.');
00394 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
00395
00396 if (opt->help)
00397 av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
00398 av_log(av_log_obj, AV_LOG_INFO, "\n");
00399 if (opt->unit && opt->type != FF_OPT_TYPE_CONST) {
00400 opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags);
00401 }
00402 }
00403 }
00404
00405 int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
00406 {
00407 if (!obj)
00408 return -1;
00409
00410 av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
00411
00412 opt_list(obj, av_log_obj, NULL, req_flags, rej_flags);
00413
00414 return 0;
00415 }
00416
00423 void av_opt_set_defaults2(void *s, int mask, int flags)
00424 {
00425 const AVOption *opt = NULL;
00426 while ((opt = av_next_option(s, opt)) != NULL) {
00427 if ((opt->flags & mask) != flags)
00428 continue;
00429 switch (opt->type) {
00430 case FF_OPT_TYPE_CONST:
00431
00432 break;
00433 case FF_OPT_TYPE_FLAGS:
00434 case FF_OPT_TYPE_INT: {
00435 int val;
00436 val = opt->default_val.dbl;
00437 av_set_int(s, opt->name, val);
00438 }
00439 break;
00440 case FF_OPT_TYPE_INT64:
00441 if ((double)(opt->default_val.dbl+0.6) == opt->default_val.dbl)
00442 av_log(s, AV_LOG_DEBUG, "loss of precision in default of %s\n", opt->name);
00443 av_set_int(s, opt->name, opt->default_val.dbl);
00444 break;
00445 case FF_OPT_TYPE_DOUBLE:
00446 case FF_OPT_TYPE_FLOAT: {
00447 double val;
00448 val = opt->default_val.dbl;
00449 av_set_double(s, opt->name, val);
00450 }
00451 break;
00452 case FF_OPT_TYPE_RATIONAL: {
00453 AVRational val;
00454 val = av_d2q(opt->default_val.dbl, INT_MAX);
00455 av_set_q(s, opt->name, val);
00456 }
00457 break;
00458 case FF_OPT_TYPE_STRING:
00459 av_set_string3(s, opt->name, opt->default_val.str, 1, NULL);
00460 break;
00461 case FF_OPT_TYPE_BINARY:
00462
00463 break;
00464 default:
00465 av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
00466 }
00467 }
00468 }
00469
00470 void av_opt_set_defaults(void *s)
00471 {
00472 av_opt_set_defaults2(s, 0, 0);
00473 }
00474
00492 static int parse_key_value_pair(void *ctx, const char **buf,
00493 const char *key_val_sep, const char *pairs_sep)
00494 {
00495 char *key = av_get_token(buf, key_val_sep);
00496 char *val;
00497 int ret;
00498
00499 if (*key && strspn(*buf, key_val_sep)) {
00500 (*buf)++;
00501 val = av_get_token(buf, pairs_sep);
00502 } else {
00503 av_log(ctx, AV_LOG_ERROR, "Missing key or no key/value separator found after key '%s'\n", key);
00504 av_free(key);
00505 return AVERROR(EINVAL);
00506 }
00507
00508 av_log(ctx, AV_LOG_DEBUG, "Setting value '%s' for key '%s'\n", val, key);
00509
00510 ret = av_set_string3(ctx, key, val, 1, NULL);
00511 if (ret == AVERROR_OPTION_NOT_FOUND)
00512 av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key);
00513
00514 av_free(key);
00515 av_free(val);
00516 return ret;
00517 }
00518
00519 int av_set_options_string(void *ctx, const char *opts,
00520 const char *key_val_sep, const char *pairs_sep)
00521 {
00522 int ret, count = 0;
00523
00524 if (!opts)
00525 return 0;
00526 while (*opts) {
00527 if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0)
00528 return ret;
00529 count++;
00530
00531 if (*opts)
00532 opts++;
00533 }
00534
00535 return count;
00536 }
00537
00538 void av_opt_free(void *obj)
00539 {
00540 const AVOption *o = NULL;
00541 while ((o = av_next_option(obj, o)))
00542 if (o->type == FF_OPT_TYPE_STRING || o->type == FF_OPT_TYPE_BINARY)
00543 av_freep((uint8_t *)obj + o->offset);
00544 }
00545
00546 int av_opt_set_dict(void *obj, AVDictionary **options)
00547 {
00548 AVDictionaryEntry *t = NULL;
00549 AVDictionary *tmp = NULL;
00550 int ret = 0;
00551
00552 while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) {
00553 ret = av_set_string3(obj, t->key, t->value, 1, NULL);
00554 if (ret == AVERROR_OPTION_NOT_FOUND)
00555 av_dict_set(&tmp, t->key, t->value, 0);
00556 else if (ret < 0) {
00557 av_log(obj, AV_LOG_ERROR, "Error setting option %s to value %s.\n", t->key, t->value);
00558 break;
00559 }
00560 ret = 0;
00561 }
00562 av_dict_free(options);
00563 *options = tmp;
00564 return ret;
00565 }
00566
00567 const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
00568 int opt_flags, int search_flags)
00569 {
00570 AVClass *c = *(AVClass**)obj;
00571 const AVOption *o = NULL;
00572
00573 if (c->opt_find && search_flags & AV_OPT_SEARCH_CHILDREN &&
00574 (o = c->opt_find(obj, name, unit, opt_flags, search_flags)))
00575 return o;
00576
00577 while (o = av_next_option(obj, o)) {
00578 if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) &&
00579 (o->flags & opt_flags) == opt_flags)
00580 return o;
00581 }
00582 return NULL;
00583 }
00584
00585 #ifdef TEST
00586
00587 #undef printf
00588
00589 typedef struct TestContext
00590 {
00591 const AVClass *class;
00592 int num;
00593 int toggle;
00594 char *string;
00595 int flags;
00596 AVRational rational;
00597 } TestContext;
00598
00599 #define OFFSET(x) offsetof(TestContext, x)
00600
00601 #define TEST_FLAG_COOL 01
00602 #define TEST_FLAG_LAME 02
00603 #define TEST_FLAG_MU 04
00604
00605 static const AVOption test_options[]= {
00606 {"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, 0, 0, 100 },
00607 {"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, 0, 0, 1 },
00608 {"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, 0, 0, 10 },
00609 {"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, 0, CHAR_MIN, CHAR_MAX },
00610 {"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, 0, 0, INT_MAX, 0, "flags" },
00611 {"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_COOL, INT_MIN, INT_MAX, 0, "flags" },
00612 {"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_LAME, INT_MIN, INT_MAX, 0, "flags" },
00613 {"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, TEST_FLAG_MU, INT_MIN, INT_MAX, 0, "flags" },
00614 {NULL},
00615 };
00616
00617 static const char *test_get_name(void *ctx)
00618 {
00619 return "test";
00620 }
00621
00622 static const AVClass test_class = {
00623 "TestContext",
00624 test_get_name,
00625 test_options
00626 };
00627
00628 int main(void)
00629 {
00630 int i;
00631
00632 printf("\nTesting av_set_options_string()\n");
00633 {
00634 TestContext test_ctx;
00635 const char *options[] = {
00636 "",
00637 ":",
00638 "=",
00639 "foo=:",
00640 ":=foo",
00641 "=foo",
00642 "foo=",
00643 "foo",
00644 "foo=val",
00645 "foo==val",
00646 "toggle=:",
00647 "string=:",
00648 "toggle=1 : foo",
00649 "toggle=100",
00650 "toggle==1",
00651 "flags=+mu-lame : num=42: toggle=0",
00652 "num=42 : string=blahblah",
00653 "rational=0 : rational=1/2 : rational=1/-1",
00654 "rational=-1/0",
00655 };
00656
00657 test_ctx.class = &test_class;
00658 av_opt_set_defaults2(&test_ctx, 0, 0);
00659 test_ctx.string = av_strdup("default");
00660
00661 av_log_set_level(AV_LOG_DEBUG);
00662
00663 for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
00664 av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
00665 if (av_set_options_string(&test_ctx, options[i], "=", ":") < 0)
00666 av_log(&test_ctx, AV_LOG_ERROR, "Error setting options string: '%s'\n", options[i]);
00667 printf("\n");
00668 }
00669 }
00670
00671 return 0;
00672 }
00673
00674 #endif