History

cmdutils: Export all sws options using a AVDictionary like the other subsystems do

This makes extracting options other than sws_flags easier

Michael Niedermayer committed 11 years ago

Commit 165fb7e1 parent 41e733c2 files · +22 −4Browse files

Unified · Split

2 files
  1. cmdutils.c +20 −4
  2. cmdutils.h +2 −0
cmdutils.c+20−4
@@ -64,6 +64,7 @@ · 63 unmodified lines
64static int init_report(const char *env);64static int init_report(const char *env);
65 65
66struct SwsContext *sws_opts;66struct SwsContext *sws_opts;
67AVDictionary *sws_dict;
67AVDictionary *swr_opts;68AVDictionary *swr_opts;
68AVDictionary *format_opts, *codec_opts, *resample_opts;69AVDictionary *format_opts, *codec_opts, *resample_opts;
69 70
@@ -77,6 +78,7 @@ void init_opts(void) · 7 unmodified lines
77 if(CONFIG_SWSCALE)78 if(CONFIG_SWSCALE)
78 sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,79 sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
79 NULL, NULL, NULL);80 NULL, NULL, NULL);
81 av_dict_set(&sws_dict, "flags", "bicubic", 0);
80}82}
81 83
82void uninit_opts(void)84void uninit_opts(void)
@@ -87,6 +89,7 @@ void uninit_opts(void) · 4 unmodified lines
87#endif89#endif
88 90
89 av_dict_free(&swr_opts);91 av_dict_free(&swr_opts);
92 av_dict_free(&sws_dict);
90 av_dict_free(&format_opts);93 av_dict_free(&format_opts);
91 av_dict_free(&codec_opts);94 av_dict_free(&codec_opts);
92 av_dict_free(&resample_opts);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#if CONFIG_SWSCALE569#if CONFIG_SWSCALE
567 sc = sws_get_class();570 sc = sws_get_class();
568 if (!consumed && opt_find(&sc, opt, NULL, 0,571 if (!consumed && (o = opt_find(&sc, opt, NULL, 0,
569 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) {572 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
570 // XXX we only support sws_flags, not arbitrary sws options573 struct SwsContext *sws = sws_alloc_context();
571 int ret = av_opt_set(sws_opts, opt, arg, 0);574 int ret = av_opt_set(sws, opt, arg, 0);
575 sws_freeContext(sws);
572 if (ret < 0) {576 if (ret < 0) {
573 av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);577 av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
574 return ret;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 consumed = 1;588 consumed = 1;
577 }589 }
578#else590#else
@@ -649,6 +661,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, · 70 unmodified lines
649#if CONFIG_SWSCALE661#if CONFIG_SWSCALE
650 g->sws_opts = sws_opts;662 g->sws_opts = sws_opts;
651#endif663#endif
664 g->sws_dict = sws_dict;
652 g->swr_opts = swr_opts;665 g->swr_opts = swr_opts;
653 g->codec_opts = codec_opts;666 g->codec_opts = codec_opts;
654 g->format_opts = format_opts;667 g->format_opts = format_opts;
@@ -660,6 +673,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, · 5 unmodified lines
660#if CONFIG_SWSCALE673#if CONFIG_SWSCALE
661 sws_opts = NULL;674 sws_opts = NULL;
662#endif675#endif
676 sws_dict = NULL;
663 swr_opts = NULL;677 swr_opts = NULL;
664 init_opts();678 init_opts();
665 679
@@ -718,6 +732,8 @@ void uninit_parse_context(OptionParseContext *octx) · 52 unmodified lines
718#if CONFIG_SWSCALE732#if CONFIG_SWSCALE
719 sws_freeContext(l->groups[j].sws_opts);733 sws_freeContext(l->groups[j].sws_opts);
720#endif734#endif
735
736 av_dict_free(&l->groups[j].sws_dict);
721 av_dict_free(&l->groups[j].swr_opts);737 av_dict_free(&l->groups[j].swr_opts);
722 }738 }
723 av_freep(&l->groups);739 av_freep(&l->groups);
cmdutils.h+2−0
@@ -47,6 +47,7 @@ extern const int program_birth_year; · 46 unmodified lines
47extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];47extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
48extern AVFormatContext *avformat_opts;48extern AVFormatContext *avformat_opts;
49extern struct SwsContext *sws_opts;49extern struct SwsContext *sws_opts;
50extern AVDictionary *sws_dict;
50extern AVDictionary *swr_opts;51extern AVDictionary *swr_opts;
51extern AVDictionary *format_opts, *codec_opts, *resample_opts;52extern AVDictionary *format_opts, *codec_opts, *resample_opts;
52extern int hide_banner;53extern int hide_banner;
@@ -278,6 +279,7 @@ typedef struct OptionGroup { · 225 unmodified lines
278 AVDictionary *format_opts;279 AVDictionary *format_opts;
279 AVDictionary *resample_opts;280 AVDictionary *resample_opts;
280 struct SwsContext *sws_opts;281 struct SwsContext *sws_opts;
282 AVDictionary *sws_dict;
281 AVDictionary *swr_opts;283 AVDictionary *swr_opts;
282} OptionGroup;284} OptionGroup;
283 285

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t