* [FFmpeg-devel] [PATCH 1/2] lavfi/(a)format: factor finding the delimiter
@ 2022-03-02 16:35 Nicolas George
2022-03-02 16:35 ` [FFmpeg-devel] [PATCH 2/2] lavfi/(a)format: support slash as a delimiter Nicolas George
0 siblings, 1 reply; 2+ messages in thread
From: Nicolas George @ 2022-03-02 16:35 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Nicolas George <george@nsup.org>
---
libavfilter/af_aformat.c | 8 +++++---
libavfilter/internal.h | 9 +++++++++
libavfilter/vf_format.c | 9 ++++-----
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index d2599431dc..0cdea2220f 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -65,10 +65,12 @@ do { \
char *next, *cur = str; \
int ret; \
\
- while (cur) { \
+ if (!cur) \
+ break; \
+ while (*cur) { \
type fmt; \
- next = strchr(cur, '|'); \
- if (next) \
+ next = ff_formats_list_find_delimiter(cur); \
+ if (*next) \
*next++ = 0; \
\
if ((fmt = get_fmt(cur)) == none) { \
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 53883101a8..74037e5eb9 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -405,4 +405,13 @@ int ff_filter_process_command(AVFilterContext *ctx, const char *cmd,
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
int default_pool_size);
+/**
+ * Find the next delimiter in a string of formats.
+ * The delimiter is '|' or the end of the string.
+ */
+static inline char *ff_formats_list_find_delimiter(const char *str)
+{
+ return (char *)str + strcspn(str, "|");
+}
+
#endif /* AVFILTER_INTERNAL_H */
diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c
index c78acbf87b..8940a0e427 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -67,10 +67,9 @@ static av_cold int init(AVFilterContext *ctx)
/* count the formats */
cur = s->pix_fmts;
- while ((cur = strchr(cur, '|'))) {
+ while (*(cur = ff_formats_list_find_delimiter(cur))) {
nb_formats++;
- if (*cur)
- cur++;
+ cur++;
}
s->formats = av_malloc_array(nb_formats + 1, sizeof(*s->formats));
@@ -80,8 +79,8 @@ static av_cold int init(AVFilterContext *ctx)
/* parse the list of formats */
cur = s->pix_fmts;
for (i = 0; i < nb_formats; i++) {
- sep = strchr(cur, '|');
- if (sep)
+ sep = ff_formats_list_find_delimiter(cur);
+ if (*sep)
*sep++ = 0;
if ((ret = ff_parse_pixel_format(&s->formats[i], cur, ctx)) < 0)
--
2.34.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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] lavfi/(a)format: support slash as a delimiter
2022-03-02 16:35 [FFmpeg-devel] [PATCH 1/2] lavfi/(a)format: factor finding the delimiter Nicolas George
@ 2022-03-02 16:35 ` Nicolas George
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas George @ 2022-03-02 16:35 UTC (permalink / raw)
To: ffmpeg-devel
Unlike pipe, slash does not require escaping.
Signed-off-by: Nicolas George <george@nsup.org>
---
doc/filters.texi | 8 ++++----
libavfilter/internal.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
Especially in makefiles, escaping is annoying.
diff --git a/doc/filters.texi b/doc/filters.texi
index 8cba7f744d..ac3091c010 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1590,13 +1590,13 @@ It accepts the following parameters:
@table @option
@item sample_fmts, f
-A '|'-separated list of requested sample formats.
+A '|'- or '/'-separated list of requested sample formats.
@item sample_rates, r
-A '|'-separated list of requested sample rates.
+A '|'- or '/'-separated list of requested sample rates.
@item channel_layouts, cl
-A '|'-separated list of requested channel layouts.
+A '|'- or '/'-separated list of requested channel layouts.
See @ref{channel layout syntax,,the Channel Layout section in the ffmpeg-utils(1) manual,ffmpeg-utils}
for the required syntax.
@@ -12811,7 +12811,7 @@ It accepts the following parameters:
@table @option
@item pix_fmts
-A '|'-separated list of pixel format names, such as
+A '|'- or '/'-separated list of pixel format names, such as
"pix_fmts=yuv420p|monow|rgb24".
@end table
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 74037e5eb9..df94b9f3b3 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -411,7 +411,7 @@ int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
*/
static inline char *ff_formats_list_find_delimiter(const char *str)
{
- return (char *)str + strcspn(str, "|");
+ return (char *)str + strcspn(str, "|/");
}
#endif /* AVFILTER_INTERNAL_H */
--
2.34.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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-02 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 16:35 [FFmpeg-devel] [PATCH 1/2] lavfi/(a)format: factor finding the delimiter Nicolas George
2022-03-02 16:35 ` [FFmpeg-devel] [PATCH 2/2] lavfi/(a)format: support slash as a delimiter Nicolas George
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