forked from FFmpeg/FFmpeg
fftools/ffmpeg_opt: add a struct to be passed as opaque to global-option handlers
Will be useful in following commits.
This commit is contained in:
parent
840b95bcc2
commit
181c204145
1 changed files with 14 additions and 7 deletions
|
@ -86,6 +86,12 @@ int ignore_unknown_streams = 0;
|
||||||
int copy_unknown_streams = 0;
|
int copy_unknown_streams = 0;
|
||||||
int recast_media = 0;
|
int recast_media = 0;
|
||||||
|
|
||||||
|
// this struct is passed as the optctx argument
|
||||||
|
// to func_arg() for global options
|
||||||
|
typedef struct GlobalOptionsContext {
|
||||||
|
Scheduler *sch;
|
||||||
|
} GlobalOptionsContext;
|
||||||
|
|
||||||
static void uninit_options(OptionsContext *o)
|
static void uninit_options(OptionsContext *o)
|
||||||
{
|
{
|
||||||
/* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */
|
/* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */
|
||||||
|
@ -611,8 +617,8 @@ static int opt_attach(void *optctx, const char *opt, const char *arg)
|
||||||
|
|
||||||
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
|
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
|
||||||
{
|
{
|
||||||
Scheduler *sch = optctx;
|
GlobalOptionsContext *go = optctx;
|
||||||
return sch_sdp_filename(sch, arg);
|
return sch_sdp_filename(go->sch, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_VAAPI
|
#if CONFIG_VAAPI
|
||||||
|
@ -1150,18 +1156,18 @@ static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
|
||||||
|
|
||||||
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
|
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
|
||||||
{
|
{
|
||||||
Scheduler *sch = optctx;
|
GlobalOptionsContext *go = optctx;
|
||||||
char *graph_desc = av_strdup(arg);
|
char *graph_desc = av_strdup(arg);
|
||||||
if (!graph_desc)
|
if (!graph_desc)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
return fg_create(NULL, graph_desc, sch);
|
return fg_create(NULL, graph_desc, go->sch);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FFMPEG_OPT_FILTER_SCRIPT
|
#if FFMPEG_OPT_FILTER_SCRIPT
|
||||||
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
|
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
|
||||||
{
|
{
|
||||||
Scheduler *sch = optctx;
|
GlobalOptionsContext *go = optctx;
|
||||||
char *graph_desc = file_read(arg);
|
char *graph_desc = file_read(arg);
|
||||||
if (!graph_desc)
|
if (!graph_desc)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
@ -1169,7 +1175,7 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
|
||||||
av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
|
av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
|
||||||
opt, arg);
|
opt, arg);
|
||||||
|
|
||||||
return fg_create(NULL, graph_desc, sch);
|
return fg_create(NULL, graph_desc, go->sch);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1346,6 +1352,7 @@ static int open_files(OptionGroupList *l, const char *inout, Scheduler *sch,
|
||||||
|
|
||||||
int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
|
int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
|
||||||
{
|
{
|
||||||
|
GlobalOptionsContext go = { .sch = sch };
|
||||||
OptionParseContext octx;
|
OptionParseContext octx;
|
||||||
const char *errmsg = NULL;
|
const char *errmsg = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1361,7 +1368,7 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* apply global options */
|
/* apply global options */
|
||||||
ret = parse_optgroup(sch, &octx.global_opts, options);
|
ret = parse_optgroup(&go, &octx.global_opts, options);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
errmsg = "parsing global options";
|
errmsg = "parsing global options";
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
Loading…
Add table
Reference in a new issue