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

This makes extracting options other than sws_flags easier

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
pull/150/head
Michael Niedermayer 10 years ago
parent 41e733c1ef
commit 165fb7eba8
  1. 24
      cmdutils.c
  2. 2
      cmdutils.h

@ -64,6 +64,7 @@
static int init_report(const char *env); static int init_report(const char *env);
struct SwsContext *sws_opts; struct SwsContext *sws_opts;
AVDictionary *sws_dict;
AVDictionary *swr_opts; AVDictionary *swr_opts;
AVDictionary *format_opts, *codec_opts, *resample_opts; AVDictionary *format_opts, *codec_opts, *resample_opts;
@ -77,6 +78,7 @@ void init_opts(void)
if(CONFIG_SWSCALE) if(CONFIG_SWSCALE)
sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC,
NULL, NULL, NULL); NULL, NULL, NULL);
av_dict_set(&sws_dict, "flags", "bicubic", 0);
} }
void uninit_opts(void) void uninit_opts(void)
@ -87,6 +89,7 @@ void uninit_opts(void)
#endif #endif
av_dict_free(&swr_opts); av_dict_free(&swr_opts);
av_dict_free(&sws_dict);
av_dict_free(&format_opts); av_dict_free(&format_opts);
av_dict_free(&codec_opts); av_dict_free(&codec_opts);
av_dict_free(&resample_opts); av_dict_free(&resample_opts);
@ -565,14 +568,23 @@ int opt_default(void *optctx, const char *opt, const char *arg)
} }
#if CONFIG_SWSCALE #if CONFIG_SWSCALE
sc = sws_get_class(); sc = sws_get_class();
if (!consumed && opt_find(&sc, opt, NULL, 0, if (!consumed && (o = opt_find(&sc, opt, NULL, 0,
AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
// XXX we only support sws_flags, not arbitrary sws options struct SwsContext *sws = sws_alloc_context();
int ret = av_opt_set(sws_opts, opt, arg, 0); int ret = av_opt_set(sws, opt, arg, 0);
sws_freeContext(sws);
if (ret < 0) { if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
return ret; return ret;
} }
ret = av_opt_set(sws_opts, opt, arg, 0);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error setting option %s for sws_opts.\n", opt);
return ret;
}
av_dict_set(&sws_dict, opt, arg, FLAGS);
consumed = 1; consumed = 1;
} }
#else #else
@ -649,6 +661,7 @@ static void finish_group(OptionParseContext *octx, int group_idx,
#if CONFIG_SWSCALE #if CONFIG_SWSCALE
g->sws_opts = sws_opts; g->sws_opts = sws_opts;
#endif #endif
g->sws_dict = sws_dict;
g->swr_opts = swr_opts; g->swr_opts = swr_opts;
g->codec_opts = codec_opts; g->codec_opts = codec_opts;
g->format_opts = format_opts; g->format_opts = format_opts;
@ -660,6 +673,7 @@ static void finish_group(OptionParseContext *octx, int group_idx,
#if CONFIG_SWSCALE #if CONFIG_SWSCALE
sws_opts = NULL; sws_opts = NULL;
#endif #endif
sws_dict = NULL;
swr_opts = NULL; swr_opts = NULL;
init_opts(); init_opts();
@ -718,6 +732,8 @@ void uninit_parse_context(OptionParseContext *octx)
#if CONFIG_SWSCALE #if CONFIG_SWSCALE
sws_freeContext(l->groups[j].sws_opts); sws_freeContext(l->groups[j].sws_opts);
#endif #endif
av_dict_free(&l->groups[j].sws_dict);
av_dict_free(&l->groups[j].swr_opts); av_dict_free(&l->groups[j].swr_opts);
} }
av_freep(&l->groups); av_freep(&l->groups);

@ -47,6 +47,7 @@ extern const int program_birth_year;
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
extern AVFormatContext *avformat_opts; extern AVFormatContext *avformat_opts;
extern struct SwsContext *sws_opts; extern struct SwsContext *sws_opts;
extern AVDictionary *sws_dict;
extern AVDictionary *swr_opts; extern AVDictionary *swr_opts;
extern AVDictionary *format_opts, *codec_opts, *resample_opts; extern AVDictionary *format_opts, *codec_opts, *resample_opts;
extern int hide_banner; extern int hide_banner;
@ -278,6 +279,7 @@ typedef struct OptionGroup {
AVDictionary *format_opts; AVDictionary *format_opts;
AVDictionary *resample_opts; AVDictionary *resample_opts;
struct SwsContext *sws_opts; struct SwsContext *sws_opts;
AVDictionary *sws_dict;
AVDictionary *swr_opts; AVDictionary *swr_opts;
} OptionGroup; } OptionGroup;

Loading…
Cancel
Save