mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-09 14:14:39 +02:00
lavfi/avfilter: export process_options()
Also, replace an AVFilterContext argument with a logging context+private class, as those are the only things needed in this function. Will be useful in future commits.
This commit is contained in:
parent
926059dbf3
commit
80cf509e73
@ -776,8 +776,8 @@ int ff_filter_get_nb_threads(AVFilterContext *ctx)
|
|||||||
return ctx->graph->nb_threads;
|
return ctx->graph->nb_threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_options(AVFilterContext *ctx, AVDictionary **options,
|
int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
|
||||||
const char *args)
|
AVDictionary **options, const char *args)
|
||||||
{
|
{
|
||||||
const AVOption *o = NULL;
|
const AVOption *o = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
@ -791,8 +791,8 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
|
|||||||
while (*args) {
|
while (*args) {
|
||||||
const char *shorthand = NULL;
|
const char *shorthand = NULL;
|
||||||
|
|
||||||
if (ctx->filter->priv_class)
|
if (priv_class)
|
||||||
o = av_opt_next(ctx->priv, o);
|
o = av_opt_next(&priv_class, o);
|
||||||
if (o) {
|
if (o) {
|
||||||
if (o->type == AV_OPT_TYPE_CONST || o->offset == offset)
|
if (o->type == AV_OPT_TYPE_CONST || o->offset == offset)
|
||||||
continue;
|
continue;
|
||||||
@ -805,9 +805,9 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
|
|||||||
&parsed_key, &value);
|
&parsed_key, &value);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (ret == AVERROR(EINVAL))
|
if (ret == AVERROR(EINVAL))
|
||||||
av_log(ctx, AV_LOG_ERROR, "No option name near '%s'\n", args);
|
av_log(logctx, AV_LOG_ERROR, "No option name near '%s'\n", args);
|
||||||
else
|
else
|
||||||
av_log(ctx, AV_LOG_ERROR, "Unable to parse '%s': %s\n", args,
|
av_log(logctx, AV_LOG_ERROR, "Unable to parse '%s': %s\n", args,
|
||||||
av_err2str(ret));
|
av_err2str(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -817,13 +817,13 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
|
|||||||
key = parsed_key;
|
key = parsed_key;
|
||||||
|
|
||||||
/* discard all remaining shorthand */
|
/* discard all remaining shorthand */
|
||||||
if (ctx->filter->priv_class)
|
if (priv_class)
|
||||||
while ((o = av_opt_next(ctx->priv, o)));
|
while ((o = av_opt_next(&priv_class, o)));
|
||||||
} else {
|
} else {
|
||||||
key = shorthand;
|
key = shorthand;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_DEBUG, "Setting '%s' to value '%s'\n", key, value);
|
av_log(logctx, AV_LOG_DEBUG, "Setting '%s' to value '%s'\n", key, value);
|
||||||
|
|
||||||
av_dict_set(options, key, value, AV_DICT_MULTIKEY);
|
av_dict_set(options, key, value, AV_DICT_MULTIKEY);
|
||||||
|
|
||||||
@ -887,7 +887,7 @@ int avfilter_init_str(AVFilterContext *filter, const char *args)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (args && *args) {
|
if (args && *args) {
|
||||||
ret = process_options(filter, &options, args);
|
ret = ff_filter_opt_parse(filter, filter->filter->priv_class, &options, args);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -405,4 +405,17 @@ int ff_filter_process_command(AVFilterContext *ctx, const char *cmd,
|
|||||||
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
|
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
|
||||||
int default_pool_size);
|
int default_pool_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse filter options into a dictionary.
|
||||||
|
*
|
||||||
|
* @param logctx context for logging
|
||||||
|
* @param priv_class a filter's private class for shorthand options or NULL
|
||||||
|
* @param options dictionary to store parsed options in
|
||||||
|
* @param args options string to parse
|
||||||
|
*
|
||||||
|
* @return a non-negative number on success, a negative error code on failure
|
||||||
|
*/
|
||||||
|
int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
|
||||||
|
AVDictionary **options, const char *args);
|
||||||
|
|
||||||
#endif /* AVFILTER_INTERNAL_H */
|
#endif /* AVFILTER_INTERNAL_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user