MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / set_string_number

Function set_string_number

libavutil/opt.c:420–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418 : opt->default_val.dbl)
419
420static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst)
421{
422 const enum AVOptionType type = TYPE_BASE(o->type);
423 int ret = 0;
424
425 if (type == AV_OPT_TYPE_RATIONAL || type == AV_OPT_TYPE_VIDEO_RATE) {
426 int num, den;
427 char c;
428 if (sscanf(val, "%d%*1[:/]%d%c", &num, &den, &c) == 2) {
429 if ((ret = write_number(obj, o, dst, 1, den, num)) >= 0)
430 return ret;
431 ret = 0;
432 }
433 }
434
435 for (;;) {
436 int i = 0;
437 char buf[256];
438 int cmd = 0;
439 double d;
440 int64_t intnum = 1;
441
442 if (type == AV_OPT_TYPE_FLAGS) {
443 if (*val == '+' || *val == '-')
444 cmd = *(val++);
445 for (; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++)
446 buf[i] = val[i];
447 buf[i] = 0;
448 }
449
450 {
451 int res;
452 int ci = 0;
453 double const_values[64];
454 const char * const_names[64];
455 int search_flags = (o->flags & AV_OPT_FLAG_CHILD_CONSTS) ? AV_OPT_SEARCH_CHILDREN : 0;
456 const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, o->unit, 0, search_flags);
457 if (o_named && o_named->type == AV_OPT_TYPE_CONST) {
458 d = DEFAULT_NUMVAL(o_named);
459 if (o_named->flags & AV_OPT_FLAG_DEPRECATED)
460 av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n",
461 o_named->name, o_named->help);
462 } else {
463 if (o->unit) {
464 for (o_named = NULL; o_named = av_opt_next(target_obj, o_named); ) {
465 if (o_named->type == AV_OPT_TYPE_CONST &&
466 o_named->unit &&
467 !strcmp(o_named->unit, o->unit)) {
468 if (ci + 6 >= FF_ARRAY_ELEMS(const_values)) {
469 av_log(obj, AV_LOG_ERROR, "const_values array too small for %s\n", o->unit);
470 return AVERROR_PATCHWELCOME;
471 }
472 const_names [ci ] = o_named->name;
473 const_values[ci++] = DEFAULT_NUMVAL(o_named);
474 }
475 }
476 }
477 const_names [ci ] = "default";

Callers 1

opt_set_elemFunction · 0.85

Calls 5

write_numberFunction · 0.85
av_opt_findFunction · 0.85
av_logFunction · 0.85
av_opt_nextFunction · 0.85
av_expr_parse_and_evalFunction · 0.85

Tested by

no test coverage detected