| 557 | } |
| 558 | |
| 559 | static int set_string_bool(void *obj, const AVOption *o, const char *val, int *dst) |
| 560 | { |
| 561 | int n; |
| 562 | |
| 563 | if (!val) |
| 564 | return 0; |
| 565 | |
| 566 | if (!strcmp(val, "auto")) { |
| 567 | n = -1; |
| 568 | } else if (av_match_name(val, "true,y,yes,enable,enabled,on")) { |
| 569 | n = 1; |
| 570 | } else if (av_match_name(val, "false,n,no,disable,disabled,off")) { |
| 571 | n = 0; |
| 572 | } else { |
| 573 | char *end = NULL; |
| 574 | n = strtol(val, &end, 10); |
| 575 | if (val + strlen(val) != end) |
| 576 | goto fail; |
| 577 | } |
| 578 | |
| 579 | if (n < o->min || n > o->max) |
| 580 | goto fail; |
| 581 | |
| 582 | *dst = n; |
| 583 | return 0; |
| 584 | |
| 585 | fail: |
| 586 | av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\" as boolean\n", o->name, val); |
| 587 | return AVERROR(EINVAL); |
| 588 | } |
| 589 | |
| 590 | static int set_string_fmt(void *obj, const AVOption *o, const char *val, uint8_t *dst, |
| 591 | int fmt_nb, int ((*get_fmt)(const char *)), const char *desc) |
no test coverage detected