diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-06-18 04:40:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-06-18 05:10:38 +0200 |
commit | 2905e3ff6462431d55f89614b24e2a407707c82a (patch) | |
tree | d482d458a449228c8475942117c7eb81ec8934c6 /cmdutils.c | |
parent | 44d1b4088f2959912a27ffbffc5884db1b35a645 (diff) | |
parent | 78440c007cd310bb27ac2af5fb7ea5b7555efc84 (diff) | |
download | ffmpeg-2905e3ff6462431d55f89614b24e2a407707c82a.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
lavc: add opt_find to AVCodecContext class.
h264: Complexify frame num gap shortening code
intreadwrite.h: fix AV_RL32/AV_RB32 signedness.
Fix decoding of mpegts streams with h264 video that does *NOT* have b frames
Add minor bumps and APIChanges entries for lavf private options.
ffmpeg: deprecate -vc and -tvstd
ffmpeg: use new avformat_open_* API.
ffserver: use new avformat_open_* API.
ffprobe: use new avformat_open_* API.
ffplay: use new avformat_open_* API.
cmdutils: add opt_default2().
dict: add AV_DICT_APPEND flag.
lavf: add avformat_write_header() as a replacement for av_write_header().
Deprecate av_open_input_* and remove their uses.
lavf: add avformat_open_input() as a replacement for av_open_input_*
AVOptions: add av_opt_find() as a replacement for av_find_opt.
AVOptions: add av_opt_set_dict() mapping a dictionary struct to a context.
ffmpeg: don't abuse a global for passing frame size from input to output
ffmpeg: don't abuse a global for passing pixel format from input to output
ffmpeg: initialise encoders earlier.
Conflicts:
cmdutils.c
doc/APIchanges
ffmpeg.c
ffplay.c
ffprobe.c
libavcodec/h264.c
libavformat/avformat.h
libavformat/utils.c
libavformat/version.h
libavutil/avutil.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'cmdutils.c')
-rw-r--r-- | cmdutils.c | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/cmdutils.c b/cmdutils.c index 1f7ecc4887..3b9cfaa3d9 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -38,6 +38,7 @@ #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/eval.h" +#include "libavutil/dict.h" #include "libavutil/opt.h" #include "cmdutils.h" #include "version.h" @@ -54,6 +55,7 @@ static int opt_name_count; AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; AVFormatContext *avformat_opts; struct SwsContext *sws_opts; +AVDictionary *format_opts, *video_opts, *audio_opts, *sub_opts; static const int this_year = 2011; @@ -86,6 +88,10 @@ void uninit_opts(void) av_freep(&opt_names); av_freep(&opt_values); opt_name_count = 0; + av_dict_free(&format_opts); + av_dict_free(&video_opts); + av_dict_free(&audio_opts); + av_dict_free(&sub_opts); } void log_callback_help(void* ptr, int level, const char* fmt, va_list vl) @@ -290,6 +296,43 @@ unknown_opt: } } +#define FLAGS (o->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 +#define SET_PREFIXED_OPTS(ch, flag, output) \ + if (opt[0] == ch && avcodec_opts[0] && (o = av_opt_find(avcodec_opts[0], opt+1, NULL, flag, 0)))\ + av_dict_set(&output, opt+1, arg, FLAGS); +static int opt_default2(const char *opt, const char *arg) +{ + const AVOption *o; + if ((o = av_opt_find(avcodec_opts[0], opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) { + if (o->flags & AV_OPT_FLAG_VIDEO_PARAM) + av_dict_set(&video_opts, opt, arg, FLAGS); + if (o->flags & AV_OPT_FLAG_AUDIO_PARAM) + av_dict_set(&audio_opts, opt, arg, FLAGS); + if (o->flags & AV_OPT_FLAG_SUBTITLE_PARAM) + av_dict_set(&sub_opts, opt, arg, FLAGS); + } else if ((o = av_opt_find(avformat_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) + av_dict_set(&format_opts, opt, arg, FLAGS); + else if ((o = av_opt_find(sws_opts, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN))) { + // XXX we only support sws_flags, not arbitrary sws options + int ret = av_set_string3(sws_opts, opt, arg, 1, NULL); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); + return ret; + } + } + + if (!o) { + SET_PREFIXED_OPTS('v', AV_OPT_FLAG_VIDEO_PARAM, video_opts) + SET_PREFIXED_OPTS('a', AV_OPT_FLAG_AUDIO_PARAM, audio_opts) + SET_PREFIXED_OPTS('s', AV_OPT_FLAG_SUBTITLE_PARAM, sub_opts) + } + + if (o) + return 0; + fprintf(stderr, "Unrecognized option '%s'\n", opt); + return AVERROR_OPTION_NOT_FOUND; +} + int opt_default(const char *opt, const char *arg){ int type; int ret= 0; @@ -322,7 +365,7 @@ int opt_default(const char *opt, const char *arg){ goto out; for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){ - const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]); + const AVOption *o2 = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], 0); if(o2) ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o); } @@ -345,11 +388,50 @@ int opt_default(const char *opt, const char *arg){ exit(1); } if (!o) { +//<<<<<<< HEAD fprintf(stderr, "Unrecognized option '%s'\n", opt); exit(1); +/*||||||| merged common ancestors + AVCodec *p = NULL; + AVOutputFormat *oformat = NULL; + while ((p=av_codec_next(p))){ + const AVClass *c = p->priv_class; + if(c && av_find_opt(&c, opt, NULL, 0, 0)) + break; + } + if (!p) { + while ((oformat = av_oformat_next(oformat))) { + const AVClass *c = oformat->priv_class; + if (c && av_find_opt(&c, opt, NULL, 0, 0)) + break; + } + } + if(!p && !oformat){ + fprintf(stderr, "Unrecognized option '%s'\n", opt); + exit(1); + } +======= + AVCodec *p = NULL; + AVOutputFormat *oformat = NULL; + while ((p=av_codec_next(p))){ + const AVClass *c = p->priv_class; + if(c && av_opt_find(&c, opt, NULL, 0, 0)) + break; + } + if (!p) { + while ((oformat = av_oformat_next(oformat))) { + const AVClass *c = oformat->priv_class; + if (c && av_opt_find(&c, opt, NULL, 0, 0)) + break; + } + } +>>>>>>> qatar/master*/ } out: + if ((ret = opt_default2(opt, arg)) < 0) + return ret; + // av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL)); opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1)); |