[FFmpeg-devel] [PATCH 07/11] Make ffmpeg use set_option(), also generalize how -*pre options work.
Stefano Sabatini
stefano.sabatini-lala
Fri Nov 12 19:31:45 CET 2010
---
cmdutils.c | 7 ++++---
cmdutils.h | 3 +++
ffmpeg.c | 8 +-------
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/cmdutils.c b/cmdutils.c
index 5f42d12..cdcea35 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -141,8 +141,8 @@ static const OptionDef* find_option(const OptionDef *po, const char *name){
return po;
}
-static int set_option(const char *ctx, const OptionDef **optdef,
- const char *opt, const char *arg, const OptionDef *options)
+int set_option(const char *ctx, const OptionDef **optdef,
+ const char *opt, const char *arg, const OptionDef *options)
{
const OptionDef *po;
int ret, bool_val = 1;
@@ -157,7 +157,8 @@ static int set_option(const char *ctx, const OptionDef **optdef,
}
if (!po->name)
po= find_option(options, "default");
- *optdef = po;
+ if (optdef)
+ *optdef = po;
if (po->flags & HAS_ARG && !arg) {
fprintf(stderr, "%s: missing argument for option '%s'\n", ctx, opt);
return AVERROR(EINVAL);
diff --git a/cmdutils.h b/cmdutils.h
index 93cdca9..69cfe2f 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -138,6 +138,9 @@ typedef struct {
void show_help_options(const OptionDef *options, const char *msg, int mask, int value);
+int set_option(const char *ctx, const OptionDef **optdef,
+ const char *opt, const char *arg, const OptionDef *options);
+
/**
* Parse the command line arguments.
* @param options Array with the definitions required to interpret every
diff --git a/ffmpeg.c b/ffmpeg.c
index 0960515..449dfe6 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -4095,13 +4095,7 @@ static int opt_preset(const char *opt, const char *arg)
fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line);
ffmpeg_exit(1);
}
- if(!strcmp(tmp, "acodec")){
- opt_audio_codec(tmp2);
- }else if(!strcmp(tmp, "vcodec")){
- opt_video_codec(tmp2);
- }else if(!strcmp(tmp, "scodec")){
- opt_subtitle_codec(tmp2);
- }else if(opt_default(tmp, tmp2) < 0){
+ if (set_option(program_name, NULL, tmp, tmp2, options) < 0) {
fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2);
ffmpeg_exit(1);
}
--
1.7.1
More information about the ffmpeg-devel
mailing list