summaryrefslogtreecommitdiff
path: root/cmdutils.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2008-12-17 23:21:33 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2008-12-17 23:21:33 +0000
commit5c3383e5b5c7e3e3c1ba86a58d3e0a1ebf521aa7 (patch)
tree47a20e22f324ddfb5bbce9580b39a17b6824b75f /cmdutils.c
parent17b17c53f437af03e323d2af5122489acbccd837 (diff)
Fix opt_default(), making it exit immediately in case of an invalid
argument. See the thread: "[PATCH] Fix opt_default()". Originally committed as revision 16196 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'cmdutils.c')
-rw-r--r--cmdutils.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/cmdutils.c b/cmdutils.c
index f52f56e7e2..9639fef8e4 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -176,25 +176,30 @@ unknown_opt:
int opt_default(const char *opt, const char *arg){
int type;
+ int ret= 0;
const AVOption *o= NULL;
int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
- for(type=0; type<CODEC_TYPE_NB; type++){
+ for(type=0; type<CODEC_TYPE_NB && ret>= 0; type++){
const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
if(o2)
- o = av_set_string2(avctx_opts[type], opt, arg, 1);
+ ret = av_set_string3(avctx_opts[type], opt, arg, 1, &o);
}
if(!o)
- o = av_set_string2(avformat_opts, opt, arg, 1);
+ ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
if(!o)
- o = av_set_string2(sws_opts, opt, arg, 1);
+ ret = av_set_string3(sws_opts, opt, arg, 1, &o);
if(!o){
if(opt[0] == 'a')
- o = av_set_string2(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1);
+ ret = av_set_string3(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg, 1, &o);
else if(opt[0] == 'v')
- o = av_set_string2(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1);
+ ret = av_set_string3(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg, 1, &o);
else if(opt[0] == 's')
- o = av_set_string2(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1);
+ ret = av_set_string3(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg, 1, &o);
+ }
+ if (o && ret < 0) {
+ fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
+ exit(1);
}
if(!o)
return -1;