Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 1/5] lavfi/avfilter: export process_options()
Date: Fri, 20 Jan 2023 20:31:28 +0100
Message-ID: <20230120193132.21597-1-anton@khirnov.net> (raw)

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.
---
 libavfilter/avfilter.c | 20 ++++++++++----------
 libavfilter/internal.h | 13 +++++++++++++
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index c2ecdffa6f..86b275dc4f 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -797,8 +797,8 @@ int ff_filter_get_nb_threads(AVFilterContext *ctx)
     return ctx->graph->nb_threads;
 }
 
-static int process_options(AVFilterContext *ctx, AVDictionary **options,
-                           const char *args)
+int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
+                        AVDictionary **options, const char *args)
 {
     const AVOption *o = NULL;
     int ret;
@@ -812,8 +812,8 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
     while (*args) {
         const char *shorthand = NULL;
 
-        if (ctx->filter->priv_class)
-            o = av_opt_next(ctx->priv, o);
+        if (priv_class)
+            o = av_opt_next(&priv_class, o);
         if (o) {
             if (o->type == AV_OPT_TYPE_CONST || o->offset == offset)
                 continue;
@@ -826,9 +826,9 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
                                    &parsed_key, &value);
         if (ret < 0) {
             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
-                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));
             return ret;
         }
@@ -838,13 +838,13 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
             key = parsed_key;
 
             /* discard all remaining shorthand */
-            if (ctx->filter->priv_class)
-                while ((o = av_opt_next(ctx->priv, o)));
+            if (priv_class)
+                while ((o = av_opt_next(&priv_class, o)));
         } else {
             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);
 
@@ -908,7 +908,7 @@ int avfilter_init_str(AVFilterContext *filter, const char *args)
     int ret = 0;
 
     if (args && *args) {
-        ret = process_options(filter, &options, args);
+        ret = ff_filter_opt_parse(filter, filter->filter->priv_class, &options, args);
         if (ret < 0)
             goto fail;
     }
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index aaf2c6c584..2ec41917f7 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -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 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 */
-- 
2.35.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

             reply	other threads:[~2023-01-20 19:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 19:31 Anton Khirnov [this message]
2023-01-20 19:31 ` [FFmpeg-devel] [PATCH 2/5] lavfi/avfilter: track whether a filter has been initialized Anton Khirnov
2023-01-20 19:31 ` [FFmpeg-devel] [PATCH 3/5] lavfi: add a new filtergraph parsing API Anton Khirnov
2023-01-30 12:59   ` Nicolas George
2023-02-01  7:02     ` Anton Khirnov
2023-02-03  9:14     ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2023-02-10  9:49       ` Anton Khirnov
2023-01-20 19:31 ` [FFmpeg-devel] [PATCH 4/5] lavfi/graphparser: reimplement avfilter_graph_parse* using new API Anton Khirnov
2023-01-20 20:47   ` Nicolas George
2023-01-20 21:11     ` Jean-Baptiste Kempf
2023-01-20 21:32       ` Nicolas George
2023-01-20 21:39         ` Nicolas George
2023-01-23 12:29           ` James Almer
2023-01-30 13:04             ` Nicolas George
2023-01-24 21:51           ` Paul B Mahol
2023-01-20 22:36     ` Anton Khirnov
2023-05-30 21:09   ` Marton Balint
2023-05-31 14:39     ` Paul B Mahol
2023-06-03 10:02     ` Anton Khirnov
2023-01-20 19:31 ` [FFmpeg-devel] [PATCH 5/5] fftools/ffmpeg: add special syntax for loading filter options from files Anton Khirnov
2023-01-23 11:34   ` Anton Khirnov
2023-01-27 16:47 ` [FFmpeg-devel] [PATCH 1/5] lavfi/avfilter: export process_options() Anton Khirnov
2023-01-27 16:48   ` Nicolas George
2023-01-27 16:51     ` Anton Khirnov
2023-01-27 16:53       ` Nicolas George

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230120193132.21597-1-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git