| 543 | |
| 544 | #define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 |
| 545 | int opt_default(void *optctx, const char *opt, const char *arg) |
| 546 | { |
| 547 | const AVOption *o; |
| 548 | int consumed = 0; |
| 549 | char opt_stripped[128]; |
| 550 | const char *p; |
| 551 | const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); |
| 552 | #if CONFIG_AVRESAMPLE |
| 553 | const AVClass *rc = avresample_get_class(); |
| 554 | #endif |
| 555 | #if CONFIG_SWSCALE |
| 556 | const AVClass *sc = sws_get_class(); |
| 557 | #endif |
| 558 | #if CONFIG_SWRESAMPLE |
| 559 | const AVClass *swr_class = swr_get_class(); |
| 560 | #endif |
| 561 | |
| 562 | if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) |
| 563 | av_log_set_level(AV_LOG_DEBUG); |
| 564 | |
| 565 | if (!(p = strchr(opt, ':'))) |
| 566 | p = opt + strlen(opt); |
| 567 | av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); |
| 568 | |
| 569 | if ((o = opt_find(&cc, opt_stripped, NULL, 0, |
| 570 | AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || |
| 571 | ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && |
| 572 | (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) { |
| 573 | av_dict_set(&codec_opts, opt, arg, FLAGS); |
| 574 | consumed = 1; |
| 575 | } |
| 576 | if ((o = opt_find(&fc, opt, NULL, 0, |
| 577 | AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { |
| 578 | av_dict_set(&format_opts, opt, arg, FLAGS); |
| 579 | if (consumed) |
| 580 | av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt); |
| 581 | consumed = 1; |
| 582 | } |
| 583 | #if CONFIG_SWSCALE |
| 584 | if (!consumed && (o = opt_find(&sc, opt, NULL, 0, |
| 585 | AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { |
| 586 | struct SwsContext *sws = sws_alloc_context(); |
| 587 | int ret = av_opt_set(sws, opt, arg, 0); |
| 588 | sws_freeContext(sws); |
| 589 | if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") || |
| 590 | !strcmp(opt, "dstw") || !strcmp(opt, "dsth") || |
| 591 | !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) { |
| 592 | av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n"); |
| 593 | return AVERROR(EINVAL); |
| 594 | } |
| 595 | if (ret < 0) { |
| 596 | av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); |
| 597 | return ret; |
| 598 | } |
| 599 | |
| 600 | av_dict_set(&sws_dict, opt, arg, FLAGS); |
| 601 | |
| 602 | consumed = 1; |
no test coverage detected