This makes extracting options other than sws_flags easier
Showing the changes to cmdutils.c (1 of 2 files). Show all
Unified · Split
| @@ -64,6 +64,7 @@ · 63 unmodified lines | ||
| 64 | 64 | static int init_report(const char *env); |
| 65 | 65 | |
| 66 | 66 | struct SwsContext *sws_opts; |
| 67 | +AVDictionary *sws_dict; | |
| 67 | 68 | AVDictionary *swr_opts; |
| 68 | 69 | AVDictionary *format_opts, *codec_opts, *resample_opts; |
| 69 | 70 | |
| @@ -77,6 +78,7 @@ void init_opts(void) · 7 unmodified lines | ||
| 77 | 78 | if(CONFIG_SWSCALE) |
| 78 | 79 | sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, |
| 79 | 80 | NULL, NULL, NULL); |
| 81 | + av_dict_set(&sws_dict, "flags", "bicubic", 0); | |
| 80 | 82 | } |
| 81 | 83 | |
| 82 | 84 | void uninit_opts(void) |
| @@ -87,6 +89,7 @@ void uninit_opts(void) · 4 unmodified lines | ||
| 87 | 89 | #endif |
| 88 | 90 | |
| 89 | 91 | av_dict_free(&swr_opts); |
| 92 | + av_dict_free(&sws_dict); | |
| 90 | 93 | av_dict_free(&format_opts); |
| 91 | 94 | av_dict_free(&codec_opts); |
| 92 | 95 | av_dict_free(&resample_opts); |
| @@ -565,14 +568,23 @@ int opt_default(void *optctx, const char *opt, const char *arg) · 472 unmodified lines | ||
| 565 | 568 | } |
| 566 | 569 | #if CONFIG_SWSCALE |
| 567 | 570 | sc = sws_get_class(); |
| 568 | − if (!consumed && opt_find(&sc, opt, NULL, 0, | |
| 569 | − AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { | |
| 570 | − // XXX we only support sws_flags, not arbitrary sws options | |
| 571 | − int ret = av_opt_set(sws_opts, opt, arg, 0); | |
| 571 | + if (!consumed && (o = opt_find(&sc, opt, NULL, 0, | |
| 572 | + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { | |
| 573 | + struct SwsContext *sws = sws_alloc_context(); | |
| 574 | + int ret = av_opt_set(sws, opt, arg, 0); | |
| 575 | + sws_freeContext(sws); | |
| 572 | 576 | if (ret < 0) { |
| 573 | 577 | av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); |
| 574 | 578 | return ret; |
| 575 | 579 | } |
| 580 | + ret = av_opt_set(sws_opts, opt, arg, 0); | |
| 581 | + if (ret < 0) { | |
| 582 | + av_log(NULL, AV_LOG_ERROR, "Error setting option %s for sws_opts.\n", opt); | |
| 583 | + return ret; | |
| 584 | + } | |
| 585 | + | |
| 586 | + av_dict_set(&sws_dict, opt, arg, FLAGS); | |
| 587 | + | |
| 576 | 588 | consumed = 1; |
| 577 | 589 | } |
| 578 | 590 | #else |
| @@ -649,6 +661,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, · 70 unmodified lines | ||
| 649 | 661 | #if CONFIG_SWSCALE |
| 650 | 662 | g->sws_opts = sws_opts; |
| 651 | 663 | #endif |
| 664 | + g->sws_dict = sws_dict; | |
| 652 | 665 | g->swr_opts = swr_opts; |
| 653 | 666 | g->codec_opts = codec_opts; |
| 654 | 667 | g->format_opts = format_opts; |
| @@ -660,6 +673,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, · 5 unmodified lines | ||
| 660 | 673 | #if CONFIG_SWSCALE |
| 661 | 674 | sws_opts = NULL; |
| 662 | 675 | #endif |
| 676 | + sws_dict = NULL; | |
| 663 | 677 | swr_opts = NULL; |
| 664 | 678 | init_opts(); |
| 665 | 679 | |
| @@ -718,6 +732,8 @@ void uninit_parse_context(OptionParseContext *octx) · 52 unmodified lines | ||
| 718 | 732 | #if CONFIG_SWSCALE |
| 719 | 733 | sws_freeContext(l->groups[j].sws_opts); |
| 720 | 734 | #endif |
| 735 | + | |
| 736 | + av_dict_free(&l->groups[j].sws_dict); | |
| 721 | 737 | av_dict_free(&l->groups[j].swr_opts); |
| 722 | 738 | } |
| 723 | 739 | av_freep(&l->groups); |