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
6464 static int init_report(const char *env);
6565
6666 struct SwsContext *sws_opts;
67+AVDictionary *sws_dict;
6768 AVDictionary *swr_opts;
6869 AVDictionary *format_opts, *codec_opts, *resample_opts;
6970
@@ -77,6 +78,7 @@ void init_opts(void) · 7 unmodified lines
7778 if(CONFIG_SWSCALE)
7879 sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
7980 NULL, NULL, NULL);
81+ av_dict_set(&sws_dict, "flags", "bicubic", 0);
8082 }
8183
8284 void uninit_opts(void)
@@ -87,6 +89,7 @@ void uninit_opts(void) · 4 unmodified lines
8789 #endif
8890
8991 av_dict_free(&swr_opts);
92+ av_dict_free(&sws_dict);
9093 av_dict_free(&format_opts);
9194 av_dict_free(&codec_opts);
9295 av_dict_free(&resample_opts);
@@ -565,14 +568,23 @@ int opt_default(void *optctx, const char *opt, const char *arg) · 472 unmodified lines
565568 }
566569 #if CONFIG_SWSCALE
567570 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);
572576 if (ret < 0) {
573577 av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
574578 return ret;
575579 }
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+
576588 consumed = 1;
577589 }
578590 #else
@@ -649,6 +661,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, · 70 unmodified lines
649661 #if CONFIG_SWSCALE
650662 g->sws_opts = sws_opts;
651663 #endif
664+ g->sws_dict = sws_dict;
652665 g->swr_opts = swr_opts;
653666 g->codec_opts = codec_opts;
654667 g->format_opts = format_opts;
@@ -660,6 +673,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, · 5 unmodified lines
660673 #if CONFIG_SWSCALE
661674 sws_opts = NULL;
662675 #endif
676+ sws_dict = NULL;
663677 swr_opts = NULL;
664678 init_opts();
665679
@@ -718,6 +732,8 @@ void uninit_parse_context(OptionParseContext *octx) · 52 unmodified lines
718732 #if CONFIG_SWSCALE
719733 sws_freeContext(l->groups[j].sws_opts);
720734 #endif
735+
736+ av_dict_free(&l->groups[j].sws_dict);
721737 av_dict_free(&l->groups[j].swr_opts);
722738 }
723739 av_freep(&l->groups);
cmdutils.h+2−0
@@ -47,6 +47,7 @@ extern const int program_birth_year; · 46 unmodified lines
4747 extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
4848 extern AVFormatContext *avformat_opts;
4949 extern struct SwsContext *sws_opts;
50+extern AVDictionary *sws_dict;
5051 extern AVDictionary *swr_opts;
5152 extern AVDictionary *format_opts, *codec_opts, *resample_opts;
5253 extern int hide_banner;
@@ -278,6 +279,7 @@ typedef struct OptionGroup { · 225 unmodified lines
278279 AVDictionary *format_opts;
279280 AVDictionary *resample_opts;
280281 struct SwsContext *sws_opts;
282+ AVDictionary *sws_dict;
281283 AVDictionary *swr_opts;
282284 } OptionGroup;
283285

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