diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-09-04 06:11:53 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-04 06:11:53 +0400 |
commit | 1889c6724a449b2e4826612d3b72efc76dbfb713 (patch) | |
tree | 05abce06cd1151955b1f1280721044584012ee51 /cmdutils.c | |
parent | ca4d71b149ebe32aeaf617ffccf362624b9aafb1 (diff) | |
parent | e955a682e125d44143415ff2b96a99a4dac78da2 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
AVOptions: fix av_set_string3() doxy to match reality.
cmdutils: get rid of dummy contexts for examining AVOptions.
lavf,lavc,sws: add {avcodec,avformat,sws}_get_class() functions.
AVOptions: add AV_OPT_SEARCH_FAKE_OBJ flag for av_opt_find().
cpu detection: avoid a signed overflow
Conflicts:
avconv.c
cmdutils.c
doc/APIchanges
ffmpeg.c
libavcodec/options.c
libavcodec/version.h
libavformat/version.h
libavutil/avutil.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'cmdutils.c')
-rw-r--r-- | cmdutils.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/cmdutils.c b/cmdutils.c index 3e34c4eb2f..bde0384c06 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -49,8 +49,6 @@ #include <sys/resource.h> #endif -AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; -AVFormatContext *avformat_opts; struct SwsContext *sws_opts; AVDictionary *format_opts, *codec_opts; @@ -58,10 +56,6 @@ static const int this_year = 2011; void init_opts(void) { - int i; - for (i = 0; i < AVMEDIA_TYPE_NB; i++) - avcodec_opts[i] = avcodec_alloc_context3(NULL); - avformat_opts = avformat_alloc_context(); #if CONFIG_SWSCALE sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NULL); #endif @@ -69,11 +63,6 @@ void init_opts(void) void uninit_opts(void) { - int i; - for (i = 0; i < AVMEDIA_TYPE_NB; i++) - av_freep(&avcodec_opts[i]); - av_freep(&avformat_opts->key); - av_freep(&avformat_opts); #if CONFIG_SWSCALE sws_freeContext(sws_opts); sws_opts = NULL; @@ -293,18 +282,19 @@ int opt_default(const char *opt, const char *arg) const AVOption *oc, *of, *os; char opt_stripped[128]; const char *p; + const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(), *sc = sws_get_class(); if (!(p = strchr(opt, ':'))) p = opt + strlen(opt); av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); - if ((oc = av_opt_find(avcodec_opts[0], opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN)) || + if ((oc = av_opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN|AV_OPT_SEARCH_FAKE_OBJ)) || ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && - (oc = av_opt_find(avcodec_opts[0], opt+1, NULL, 0, 0)))) + (oc = av_opt_find(&cc, opt+1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) av_dict_set(&codec_opts, opt, arg, FLAGS(oc)); - if ((of = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) + if ((of = av_opt_find(&fc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) av_dict_set(&format_opts, opt, arg, FLAGS(of)); - if ((os = av_opt_find(sws_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) { + if ((os = av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { // XXX we only support sws_flags, not arbitrary sws options int ret = av_set_string3(sws_opts, opt, arg, 1, NULL); if (ret < 0) { @@ -831,6 +821,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFor AVCodec *codec = s->oformat ? avcodec_find_encoder(codec_id) : avcodec_find_decoder(codec_id); int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM; char prefix = 0; + const AVClass *cc = avcodec_get_class(); if (!codec) return NULL; @@ -852,10 +843,10 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, AVFor default: return NULL; } - if (av_opt_find(avcodec_opts[0], t->key, NULL, flags, 0) || - (codec && codec->priv_class && av_opt_find(&codec->priv_class, t->key, NULL, flags, 0))) + if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) || + (codec && codec->priv_class && av_opt_find(&codec->priv_class, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ))) av_dict_set(&ret, t->key, t->value, 0); - else if (t->key[0] == prefix && av_opt_find(avcodec_opts[0], t->key+1, NULL, flags, 0)) + else if (t->key[0] == prefix && av_opt_find(&cc, t->key+1, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ)) av_dict_set(&ret, t->key+1, t->value, 0); if (p) |