From patchwork Wed Mar 2 16:35:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34573 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4799062nkx; Wed, 2 Mar 2022 08:36:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyt7bcUrFoLr2MdePUhZwVeTDg5duuTmftz+WMxirSf/pLxglXsgYLfeInZI2HQl18jdoXo X-Received: by 2002:a05:6402:1908:b0:412:ee38:4186 with SMTP id e8-20020a056402190800b00412ee384186mr30018293edz.221.1646238975142; Wed, 02 Mar 2022 08:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646238975; cv=none; d=google.com; s=arc-20160816; b=fzHVkGTrndgJJ9bCFu9Ue0Vpi6XkdC6lSsdQJDVpsY0ut7r1zhMVEoVtZnHkmFbM5d ckGd4Qkmx0t+VdTe+JQeMTJAyfxDQFaFnC9z2yK1lRkp9Ja3aLaz3Vd+jFFUd+e+QcDu ZUriOjh8OGUVzRsi3YrPSbgnh/O64xb2iIpmyUc6JFROZy7iUi/e3zyROCJiy52OIPyq S6PgleO/yog2MPSwGkMRrhNd+xJX+ksgCYfo/B0vDw2vzikHdzr+Qb4PwcuI7Ry8LBfl Zo3JHNKuSa/hSgi8Ik1DfEF0vd0n8KWhyrDDaWIoh2zzzBvu3eFCyhGnWIt/hzivK6vU hX6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=fqBfaZ8lWSqy2cpII9k6AE1ZU6LFWrRmhxzJ/gpNrF4=; b=gXXiuaPgi7QqSDWRbDeRtzdOLqGMNV6jzzQZufyIBpoia9SGEy5g23274lO6f5fcVC rKkb5SawnHT81IWnoMD7KhLzcZxI7/aLCZZvH7JDsrPm6+E8xBhSG3o5WOFBemJcm7ak GTAHux4j4wUH1x+hlRayz9JO9P82kyG5T1fm6AOUZJd8EbLhSiBr3Mjl2yEOy+BuPkGk C7/fMrY51J0TMs1pOQayT8BYbZpOVQkTTzpxB41usZmvFfUS60NE7aEEPFQN0RDULAgt idVTT6m+x2upuhtjZn8gJd8v/06JfiiDT+vrRnY0/csyIPOz2LeFIDyZMOEV4GgitG7h MpQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b10-20020a50e38a000000b003ff3226d58bsi12047445edm.218.2022.03.02.08.35.51; Wed, 02 Mar 2022 08:36:15 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4930D68B2D2; Wed, 2 Mar 2022 18:35:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3B56568B015 for ; Wed, 2 Mar 2022 18:35:42 +0200 (EET) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 222GZfwF027335 for ; Wed, 2 Mar 2022 17:35:41 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 4A553E62AD; Wed, 2 Mar 2022 17:35:41 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 17:35:38 +0100 Message-Id: <20220302163539.273347-1-george@nsup.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Wed, 02 Mar 2022 17:35:41 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 1/2] lavfi/(a)format: factor finding the delimiter X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 3pyVGvThUsNc Signed-off-by: Nicolas George --- 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) From patchwork Wed Mar 2 16:35:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34574 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4799187nkx; Wed, 2 Mar 2022 08:36:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdzSP8Va8femgkQ1R4Vd9+S37wDlJ8SwWQFWPvfmx1wh6iNMNrAt0JxyooGpK1oylRQNSB X-Received: by 2002:a50:e696:0:b0:413:3846:20a9 with SMTP id z22-20020a50e696000000b00413384620a9mr30174316edm.96.1646238982653; Wed, 02 Mar 2022 08:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646238982; cv=none; d=google.com; s=arc-20160816; b=anMN6AmQGPe5XbbQP9r9h7ds99of8pPJENM6cJEmmRIkfqUef70ElTGOihdnEjhyIG E4GzSqZoEgCec/YodVkkPb4J62P2S+ehe//f+Psq+JPz+ZOoI5MMvax9238ovwMcmRsf U/+v2WMXFyjl8P1DspQqfp0YutRpjQSdUC/1xwi6Jq6yi4p8KfRp7yxf0vtjQRQr/aB4 vL4tWOMKRn4B47aQ+w4NnQxRoo394PPx5jPyxgLHGGkI1c8494qVUdx2h+QPrHBPfYRn zqVzCYGjAHonMjEbIFzZqbuq+t3WInGJI9kcctFaS2/S3i8Uc0YUlICQndntHhVrZMkQ ExxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=MZrzNsfwU5vIwstcra5p8GA0uv2ttejx9D9Y27ZjWE8=; b=a++IzJZSdYV0BBR12SwIMiAuPhA8q6Fs/KekIq2vXc38SOwQSChkmAOcueGpxND92s AUoeUtXzha8C2vBS76Xoy5oD0/dvoK9EPTfkGQcyboucHxDqBQe0qMBppj05h/zWelrj KY3cH2j70OTRSkE+ANkul/OjnXVgyuZpcpKEZRJ3DsETtEyLy/ylIFbBXZBLWBuUwTxi Efi3efP3qSpEFOijPmMHnrDvCv0NAqrL+PTTSQXFrZLw/lTLVKU8Y9a76n89PC8sbIl1 pIO7G/RFCs7oLi4skbSUpqvbbtI7Wx6c0OHiRcdYr9koV1sGn1iMlGm+3XXpcAuQnFK7 bhqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fj11-20020a1709069c8b00b006d131523f6fsi7942444ejc.554.2022.03.02.08.36.01; Wed, 02 Mar 2022 08:36:22 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3D3C668B2CC; Wed, 2 Mar 2022 18:35:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 58B6268B119 for ; Wed, 2 Mar 2022 18:35:42 +0200 (EET) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 222GZfRu027336 for ; Wed, 2 Mar 2022 17:35:41 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 7F655EB5BC; Wed, 2 Mar 2022 17:35:41 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 17:35:39 +0100 Message-Id: <20220302163539.273347-2-george@nsup.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302163539.273347-1-george@nsup.org> References: <20220302163539.273347-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Wed, 02 Mar 2022 17:35:41 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/(a)format: support slash as a delimiter X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: UZO885+iVMRj Unlike pipe, slash does not require escaping. Signed-off-by: Nicolas George --- 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 */