From patchwork Wed Mar 2 18:40:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34584 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4904229nkx; Wed, 2 Mar 2022 10:41:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxa2Vedv+RGUS1QkKRe8p/B0OiD0s1Or4MIOAqJYulXEqHgNCBsA9m4dL2RIBYpFCm8Sbva X-Received: by 2002:a50:e08c:0:b0:407:cdc6:809e with SMTP id f12-20020a50e08c000000b00407cdc6809emr30270271edl.162.1646246467086; Wed, 02 Mar 2022 10:41:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646246467; cv=none; d=google.com; s=arc-20160816; b=r2q0FHDTpH9ErwjR4IFHuqK/WDsetSRPJX+7wICih80/X8VdbXrJ3WWq6JDJq/IXA3 hvWR4kMxATvIhgni+He2sxilFybujvPSDXzBCGXpUx1xQ3gi0f1rOJq7vaR6FoIbtEpK bF1H3uLzpx6aBdg1VbwxJDsD8YSJoZS67lD1q1B4+ko5eAizp+6SCdHb8UBVw6P1jn0t O9IwDgKyygTKbwgWf/U8XHU3lZcrlDdWDj7UWNZReQuuDYJzhsfsXaKTVA+XF0CnspHI BGrI7hmgLBR9t+fcsNCENHpKcnsfScwWDvUfhX6gS4orq/AKzvRDn/oqtuqhjl/D2ze1 EvRw== 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=lk1KFGCP8Y3Au0vO/Qs7Xr33g0ujzoPEBmN1pOWvRPo=; b=bNdwJCdupy1g3/BxIRUjAytAoNAcBoRneHyHJa2aFYDbMSkQ1EM+4H+/aUvmrRZ8// 36pCOo142r+57b06gqz0zpZv9qOId0okTOCsp5qoNev+jQ0ow8Fz3za5AUw+L9LhHa23 alFdkRRFONeR9RacgCi0EleRWBvWknIwZv4gcgJ4yRoCjGNvKNjg0u03Kw1zFz1lgq3a SRLPe//Q6uf2S+PqdfaGfUb5Ul2bjVSU0fK153uGgCByqrj4CoMP6FoQJQ/EsJV3ZNpU q4Dg1D7AN22e0S8RD19HkfOpHF8cnyv0MoLTJywuV79OwmMg3Jmp9KrkBylaMyAolId5 q+rw== 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 y18-20020a056402271200b00410d7262743si14322853edd.568.2022.03.02.10.40.45; Wed, 02 Mar 2022 10:41:07 -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 E116B68B1FF; Wed, 2 Mar 2022 20:40:32 +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 BDA3268B31C for ; Wed, 2 Mar 2022 20:40:25 +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 222IeOx5010650 for ; Wed, 2 Mar 2022 19:40:25 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id AFE2AE62AD; Wed, 2 Mar 2022 19:40:24 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 19:40:19 +0100 Message-Id: <20220302184023.285022-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 19:40:25 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 1/5] lavfi/graphdump: add plain listing output 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: B0mcf4HeQ64h Signed-off-by: Nicolas George --- libavfilter/avfilter.h | 5 ++- libavfilter/graphdump.c | 79 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 4 deletions(-) Unchanged since last summer. The last patch is what this is needed for. diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index b105dc3159..b338766609 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -1153,7 +1153,10 @@ int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const * Dump a graph into a human-readable string representation. * * @param graph the graph to dump - * @param options formatting options; currently ignored + * @param options formatting options; can be NULL, empty + * or "f=aa" for clumsy ascii-art drawing, + * or "f=tech" for plain listing; + * other values silently ignored * @return a string, or NULL in case of memory allocation failure; * the string must be freed using av_free */ diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c index cf8914b558..80dbccc66a 100644 --- a/libavfilter/graphdump.c +++ b/libavfilter/graphdump.c @@ -27,6 +27,9 @@ #include "avfilter.h" #include "internal.h" +#define FORMAT_AA 0 +#define FORMAT_TECH 1 + static int print_link_prop(AVBPrint *buf, AVFilterLink *link) { const char *format; @@ -60,7 +63,51 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link) return buf->len; } -static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph) +static inline const char *fcname(const AVFilterContext *filter) +{ + return filter->name ? filter->name : ""; +} + +static void dump_tech(AVBPrint *buf, AVFilterGraph *graph) +{ + unsigned i, j; + + for (i = 0; i < graph->nb_filters; i++) { + AVFilterContext *filter = graph->filters[i]; + + if (i) + av_bprintf(buf, "\n"); + av_bprintf(buf, "Filter: %s (%s)\n", fcname(filter), filter->filter->name); + + for (j = 0; j < filter->nb_inputs; j++) { + AVFilterPad *pad = &filter->input_pads[j]; + AVFilterLink *link = filter->inputs[j]; + AVFilterPad *ppad = link->srcpad; + AVFilterContext *peer = link->src; + + av_bprintf(buf, " in %d: %s ← %s.%d:%s ", + j, pad->name, + fcname(peer), FF_OUTLINK_IDX(link), ppad->name); + print_link_prop(buf, link); + av_bprintf(buf, "\n"); + } + + for (j = 0; j < filter->nb_outputs; j++) { + AVFilterPad *pad = &filter->output_pads[j]; + AVFilterLink *link = filter->outputs[j]; + AVFilterPad *ppad = link->dstpad; + AVFilterContext *peer = link->dst; + + av_bprintf(buf, " out %d: %s → %s.%d:%s ", + j, pad->name, + fcname(peer), FF_INLINK_IDX(link), ppad->name); + print_link_prop(buf, link); + av_bprintf(buf, "\n"); + } + } +} + +static void dump_ascii_art(AVBPrint *buf, AVFilterGraph *graph) { unsigned i, j, x, e; @@ -152,17 +199,43 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph) } } +static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph, const char *options) +{ + unsigned format = FORMAT_AA; + + /* For a very long time, options was ignored. + Having a string for that task was a mistake, but it is not important. + It is not worth a proper parsing. + */ + if (options && *options) { + if (!strcmp("f=aa", options)) { + format = FORMAT_AA; + } else if (!strcmp("f=tech", options)) { + format = FORMAT_TECH; + } + /* ignore other values */ + } + switch (format) { + case FORMAT_AA: + dump_ascii_art(buf, graph); + break; + case FORMAT_TECH: + dump_tech(buf, graph); + break; + } +} + char *avfilter_graph_dump(AVFilterGraph *graph, const char *options) { AVBPrint buf; char *dump = NULL; av_bprint_init(&buf, 0, AV_BPRINT_SIZE_COUNT_ONLY); - avfilter_graph_dump_to_buf(&buf, graph); + avfilter_graph_dump_to_buf(&buf, graph, options); dump = av_malloc(buf.len + 1); if (!dump) return NULL; av_bprint_init_for_buffer(&buf, dump, buf.len + 1); - avfilter_graph_dump_to_buf(&buf, graph); + avfilter_graph_dump_to_buf(&buf, graph, options); return dump; } From patchwork Wed Mar 2 18:40:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34583 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4904124nkx; Wed, 2 Mar 2022 10:40:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzA1mwR85dlf2w46zbRNCIp5EYBbJiCQPi4nUp3nk40+2dGQ3ri3t0d8f1UmmRdpXZ+yICU X-Received: by 2002:a17:906:9743:b0:6d8:632a:a42d with SMTP id o3-20020a170906974300b006d8632aa42dmr4477835ejy.157.1646246458168; Wed, 02 Mar 2022 10:40:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646246458; cv=none; d=google.com; s=arc-20160816; b=kOVlpwWe1G1U9gflegKU4N09/b7N7JzBJeyL0M2u5da/AhL/ly2kexA7B0kKW+k94V KzzcQ0rcrL0oOm4x4R7Ft/YmoFB1tbUlAistZgAC3x1NqFB9DVEMEDrpsKwBPs089by0 lqudhkfwohdKBjoZucQHKI1t5SknFqKnVRbS6Ur8K83YWjvOuQ5hZHifGl0BJOP5lK4j kYeGj89etGcASoNq3UCb/CpLmFeKXnd7YjHuEgNFpYDyJWweabVV/vfisv1wB+kSv7+r 9nCzbs15PqVVJCmK1Oqo3OqIAMlKgb27rd9K30e21Zlp6oUgSVWjB/k0nJeLXJ5yyaai /4vA== 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=vEAOUYlMbK1eC0YL59450enbRHi17YW+CPikFMHOkI0=; b=uIZl+i3uft2vTcdy5j3CRiDadMbYan+VIwTINCkkWwRLcsM8k4tRWnn0zsDP2SZVF+ PUeXYZeL6do24hloV6H1/ARJQ7cf9MvAzqImAOPGwD46txND9EVR/+o/iqF7Ew6I2MfN TruF1ByN7rSUBlJTg6ZdwfsgvuNi34rG+KGsfhAhfd0LxKWoWZFn/WbKcTXArBbmQVSh f9/1oOCA9uZkIaRCm5ap52PnnafHHbJisqddKumCcQ2y7HRtM0jWwXSLG8o95a6oKedS wV9W5Is6Tw3YXMD5yRTp3GRPhpDkoHymrOfNpDVEjzUChVxRsp4JuQlvzUXz0ZnB4BFQ FHpQ== 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 i38-20020a0564020f2600b004108264e75esi11512039eda.548.2022.03.02.10.40.34; Wed, 02 Mar 2022 10:40:58 -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 1069668B34A; Wed, 2 Mar 2022 20:40:32 +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 B69AD68B318 for ; Wed, 2 Mar 2022 20:40:25 +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 222IeOaa010651 for ; Wed, 2 Mar 2022 19:40:25 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id E7099EB5BC; Wed, 2 Mar 2022 19:40:24 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 19:40:20 +0100 Message-Id: <20220302184023.285022-2-george@nsup.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302184023.285022-1-george@nsup.org> References: <20220302184023.285022-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 19:40:25 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 2/5] fftools: add -lavfi_dump option 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: BP4jzUSeKxqw Signed-off-by: Nicolas George --- doc/ffmpeg.texi | 4 ++++ fftools/ffmpeg.h | 1 + fftools/ffmpeg_filter.c | 14 ++++++++++++++ fftools/ffmpeg_opt.c | 3 +++ 4 files changed, 22 insertions(+) Unchanged since last summer. diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 164419cad3..1f6c416390 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1864,6 +1864,10 @@ The default is the number of available CPUs. Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs. Equivalent to @option{-filter_complex}. +@anchor{lavfi_dump option} +@item -lavfi_dump (@emph{global}) +Dump the filter graphs and their negotiated formats to standard output. + @item -filter_complex_script @var{filename} (@emph{global}) This option is similar to @option{-filter_complex}, the only difference is that its argument is the name of the file from which a complex filtergraph diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index cc8f767e5d..4b81cc19fa 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -635,6 +635,7 @@ extern char *filter_nbthreads; extern int filter_complex_nbthreads; extern int vstats_version; extern int auto_conversion_filters; +extern int dump_filtergraphs; extern const AVIOInterruptCB int_cb; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index b80d7189db..33ed91bf63 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1070,6 +1070,20 @@ int configure_filtergraph(FilterGraph *fg) avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE); if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0) goto fail; + if (dump_filtergraphs) { + char *dump = avfilter_graph_dump(fg->graph, "f=tech"); + if (!dump) + return AVERROR(ENOMEM); + if (simple) { + OutputStream *ost = fg->outputs[0]->ost; + printf("Dump of filter graph for output #%d:%d:", ost->file_index, ost->index); + } else { + printf("Dump of complex filter graph #%d:", fg->index); + } + printf("\n\n%s\n", dump); + av_free(dump); + fflush(stdout); + } fg->is_meta = graph_is_meta(fg->graph); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index bf1bbcae4c..9b09917bb3 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -167,6 +167,7 @@ char *filter_nbthreads; int filter_complex_nbthreads = 0; int vstats_version = 2; int auto_conversion_filters = 1; +int dump_filtergraphs = 0; int64_t stats_period = 500000; @@ -3670,6 +3671,8 @@ const OptionDef options[] = { "number of threads for -filter_complex" }, { "lavfi", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex }, "create a complex filtergraph", "graph_description" }, + { "lavfi_dump", OPT_BOOL | OPT_EXPERT, { &dump_filtergraphs }, + "dump filter graphs to standard output" }, { "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script }, "read complex filtergraph description from a file", "filename" }, { "auto_conversion_filters", OPT_BOOL | OPT_EXPERT, { &auto_conversion_filters }, From patchwork Wed Mar 2 18:40:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34585 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4904252nkx; Wed, 2 Mar 2022 10:41:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJygyeQyHY2d6pnPuimI2f1vKqi5rlv2nnjNIObmY2udlm958yUqh/kQSBTpk75zDCKvDU4X X-Received: by 2002:a17:906:6716:b0:6cc:7d95:90af with SMTP id a22-20020a170906671600b006cc7d9590afmr23360695ejp.442.1646246469697; Wed, 02 Mar 2022 10:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646246469; cv=none; d=google.com; s=arc-20160816; b=lRYS6b168gYOA7/D1Tkos+nupC4w238P01jPP8FfDS7hFVTRWEB4idSa6MbTcH7Rdc a6B+AKu1PfFLSmwg+PTl4jq2zie9Cl7IbDWonNn5To5jtE0pzPihDgTUAuJZAKCc8RMk aRu+tAvMZeTF/3WweLsbk9aVxp1hFgRFp8OuD+VU3ZIMKdICtDNKRfFhVLU/KZcE654e GINjtiYj/O8ggtefCyrpIiLjpDTcZ7CaD1km3eS2tQqutEU9ANGxNwuwiDgR0FuszoX1 S87hKQJdp8dKN2zlFeFgQEZBHFj58bVTODbuO7Gj4MAw05i+CVTXiwqPsiedTM929UDm PieQ== 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=J+/1VWKKLm6nEu8M8ej9pjvLY2Krv2L44SttCA59z64=; b=hKBlh/pbvjNEXpV+CjmXDZ/zNKw1hPcomjhpH1ZUMeh7EUUtYK+roupVyNhoPtEgvH 306EYfXV4fUh77oaJNhbSFJrjIl3bqhxxPSrJw/UIu47o8AB8OUDSZ9XCVrAf4Hw4Q5P S1f3jES31QZAsGN2gIRBEOj7JADV/LfHARgD9kXBBYjugsXLv+6u6VZP1u+0GxfXLruX oVLj95Zqu6m9SK4pB3gvX7FEYN92NKYHRfMQDF+Mu6YNUpUp42AUDzJYhi8/QVVtdiTN 4XVa9/WgzPFWECQNx6qOwCzAdMHqdTcoX5ZLSdxH6pObVKS+/BsyuFxs9kCRnUE+AidK +xwg== 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 co28-20020a0564020c1c00b00410a632cf1asi10919453edb.228.2022.03.02.10.40.57; Wed, 02 Mar 2022 10:41:09 -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 B09EB68B362; Wed, 2 Mar 2022 20:40:33 +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 0BE8A68B31C for ; Wed, 2 Mar 2022 20:40:25 +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 222IePTB010653 for ; Wed, 2 Mar 2022 19:40:25 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 27FA2EB5BD; Wed, 2 Mar 2022 19:40:25 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 19:40:21 +0100 Message-Id: <20220302184023.285022-3-george@nsup.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302184023.285022-1-george@nsup.org> References: <20220302184023.285022-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 19:40:25 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 3/5] 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: NOEOKYw7sjcU 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(-) Same as sent earlier today. 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 18:40:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34586 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4904250nkx; Wed, 2 Mar 2022 10:41:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsHXyYHJIpRX18lMQSWub6cqI8fKt84J6lfwJp41w5dLeocxI6KCvESgvSZabkt/9cOtnu X-Received: by 2002:a17:907:2d06:b0:6da:688d:9668 with SMTP id gs6-20020a1709072d0600b006da688d9668mr2752624ejc.19.1646246469380; Wed, 02 Mar 2022 10:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646246469; cv=none; d=google.com; s=arc-20160816; b=yMYpDRyAtjr72Gvs4N64PDfZqG8sGw4KICb/3Mj0j75ToHUYLx6ayznoqD3IktVO/s wDsUTZkha5pst0J/K2XYtsywm4I14XbPdyGWLfe6aERxoi/uLSFouR+glQLZi+7Xw4/Y znUFWHE0AoaLzxmCKbouDFK9OSTTUprGGGH0RJzFi8vMxOsO8bO4k5KBE23Nnmgr0IHh WMXMr9mxUPAKZ+M753B+QBs8Szbdx0oP/LpAWu36VeDPNVxg9Asu2TgENDXeFgXloB4E 6X9yeprFFjR9L2yns9cla52SbA98MprOcfw9W8NfxM3rKSILELIlgvAoSI2wQ1FksI1b /4IQ== 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=hmH3Zlwzc7t9ZDhwjlfX0Q3il03rYXd3qUmcCDCX4zY=; b=jonKUcJMuC7nteQkM1VWOFZhJqMDtkK+FU+Vk4JgOnW4aePVdMhplC0eNWHm24GC/0 FbgYaWPTqRLWIZ4RrABMCtPeTdcCuCfp+ZMI/I0ldYRJv3UY9avvwJk+b4rrnwHlhPQM a4AwCgTdXsviLNCgV8Yx2wNmelWysVPwkHHXS9WG0hcW/8Z20FQ0wj+hAIFgl0BSPlLQ 178jKwMvhFASP0rTwHoIpo5XRgoc+/7n+HjQbwJWf4MD/d0leCVE2t3cAIUX03GiV5ss S3okOHAnOUruyuZVCB7A3lt5HHVGGxS7OJTT3gQHCMN6C9g3jEjumrvZb/LtI5KGkmXt mGqg== 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 z11-20020a05640240cb00b00415c5b25e91si1301065edb.596.2022.03.02.10.41.09; Wed, 02 Mar 2022 10:41:09 -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 A3E1968B368; Wed, 2 Mar 2022 20:40:34 +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 2BF8E68B327 for ; Wed, 2 Mar 2022 20:40:26 +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 222IePKg010658 for ; Wed, 2 Mar 2022 19:40:25 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 5B027E62AD; Wed, 2 Mar 2022 19:40:25 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 19:40:22 +0100 Message-Id: <20220302184023.285022-4-george@nsup.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302184023.285022-1-george@nsup.org> References: <20220302184023.285022-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 19:40:25 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 4/5] 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: muek4/MXKXl3 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(-) Same as sent earlier today. 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 */ From patchwork Wed Mar 2 18:40:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 34587 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4904425nkx; Wed, 2 Mar 2022 10:41:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0YHrrDjhEvBaqrWc8J6BjmGN9wPYm3DATS3u3m1X3xirJkgZ6ik6ciOsDTySjtCRYhotD X-Received: by 2002:a17:906:1be1:b0:6ce:b0a8:17d with SMTP id t1-20020a1709061be100b006ceb0a8017dmr23447432ejg.413.1646246481626; Wed, 02 Mar 2022 10:41:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646246481; cv=none; d=google.com; s=arc-20160816; b=J0OcgopyWTsoPsizMktXg+5WfvKCf2ezXZ4OSHp3OP3o41zJlnMy9S1RzG2mzhy/Le RzC3xztbrhBQHCq7ARd071tSAmZJo3SJhqJo6NHFN2aUyBapo2/dk68GkiOdmg7wsnNJ 2KIIUU1IY2IHO3DEzwMiJCtClS+R4Hcv0utM/YH5mhGxMI4pOIAac4Pqe1Yvo9ZWBxna 6mUG8jcRjSdXX2UkrvWvAwPyBTlmYRZcJxEXc0lFcJULAXL6gAwnL/gxbN5x+26GNIGJ Ier7SjDob1gC7FEFiIgBpsVzyhGYRhj2rezvN6MVV7U0n5P8TruAn4aPiQMR/mzmxyBw zXtg== 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=a0+s+ecMsb+Mq0Eg56J4KrFwxAwBoHh1j1mdwu49m2I=; b=r/EemTLktwoVn/xelr3rwTY3Q9dudic2AWkoZAs9r+a6QOqcEsLlHepX+na/O1GhNV 9mK5klOXiP0cC5a3cu9udNJUVlC62NAJn8XHUj+YewwzgTwbq7ppzE0TcPy3sIGXz0wl whA8PTbi04HM/PjqllPNxe8IWo10vmQ1nfIgRjYaKtQW2kuu75//kU5vGtjS3si6cVKp Yg4EH9tkEYq5HOS5+t0kGZNKzaAoZII9Oy2gCsJdPerVtVAiJtXgjGROcR/MNAVaV3X6 IdOkt4A0LVxXgNzANwD+1FfrsySgJBUcD1rk+3mv58cMa1DU0SiB+fG8x5rITdPFrXkL CvNg== 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 g21-20020a170906869500b006c55cd84a72si9405817ejx.446.2022.03.02.10.41.20; Wed, 02 Mar 2022 10:41:21 -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 7EF4F68B320; Wed, 2 Mar 2022 20:40:35 +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 68BB268B327 for ; Wed, 2 Mar 2022 20:40:26 +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 222IePYi010663 for ; Wed, 2 Mar 2022 19:40:25 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id 8E116EB5BC; Wed, 2 Mar 2022 19:40:25 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 19:40:23 +0100 Message-Id: <20220302184023.285022-5-george@nsup.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302184023.285022-1-george@nsup.org> References: <20220302184023.285022-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 19:40:25 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 5/5] tests: add coverage for libavfilter's format negotiation 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: J86FSu0BEg2u Signed-off-by: Nicolas George --- tests/Makefile | 1 + tests/fate-run.sh | 4 ++++ tests/fate/libavfilter.mak | 9 +++++++++ tests/ref/fate/libavfilter-negotiation-alpha | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/fate/libavfilter.mak create mode 100644 tests/ref/fate/libavfilter-negotiation-alpha This is not to be the only test, I intend to cover all the logic in pick_format() and the logic in swap_*(). But I would rather have you have a quick look at the makefile hackery before writing too many tests that would need changing. diff --git a/tests/Makefile b/tests/Makefile index c4c31ae871..2bff4b339d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -157,6 +157,7 @@ include $(SRC_PATH)/tests/fate/imf.mak include $(SRC_PATH)/tests/fate/indeo.mak include $(SRC_PATH)/tests/fate/libavcodec.mak include $(SRC_PATH)/tests/fate/libavdevice.mak +include $(SRC_PATH)/tests/fate/libavfilter.mak include $(SRC_PATH)/tests/fate/libavformat.mak include $(SRC_PATH)/tests/fate/libavutil.mak include $(SRC_PATH)/tests/fate/libswresample.mak diff --git a/tests/fate-run.sh b/tests/fate-run.sh index fbfc0a925d..82d40f5ebc 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -509,6 +509,10 @@ venc_data(){ run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type} } +lavfi_dump(){ + run ffmpeg${PROGSUF}${EXECSUF} -lavfi_dump -lavfi "$@" -f null - +} + null(){ : } diff --git a/tests/fate/libavfilter.mak b/tests/fate/libavfilter.mak new file mode 100644 index 0000000000..692f1d4960 --- /dev/null +++ b/tests/fate/libavfilter.mak @@ -0,0 +1,9 @@ +# avfiltergraph.c : pick_format() : video / don't lose alpha +FATE_LIBAVFILTER_NEGOTIATION_VIDEO += fate-libavfilter-negotiation-alpha +fate-libavfilter-negotiation-alpha: CMD = lavfi_dump testsrc2=d=0,format=rgba,scale,format=yuv444p/yuva444p + +FATE_LIBAVFILTER-$(call ALLYES, TESTSRC2_FILTER FORMAT_FILTER SCALE_FILTER) += $(FATE_LIBAVFILTER_NEGOTIATION_VIDEO) + +fate-libavfilter: $(FATE_LIBAVFILTER) $(FATE_LIBAVFILTER-yes) +fate-libavfilter-negotiation: $(FATE_LIBAVFILTER_NEGOTIATION) $(FATE_LIBAVFILTER_NEGOTIATION-yes) +FATE_FFMPEG += $(FATE_LIBAVFILTER-yes) diff --git a/tests/ref/fate/libavfilter-negotiation-alpha b/tests/ref/fate/libavfilter-negotiation-alpha new file mode 100644 index 0000000000..00175f65cb --- /dev/null +++ b/tests/ref/fate/libavfilter-negotiation-alpha @@ -0,0 +1,20 @@ +Dump of complex filter graph #0: + +Filter: Parsed_testsrc2_0 (testsrc2) + out 0: default → Parsed_format_1.0:default [320x240 1:1 rgba] + +Filter: Parsed_format_1 (format) + in 0: default ← Parsed_testsrc2_0.0:default [320x240 1:1 rgba] + out 0: default → Parsed_scale_2.0:default [320x240 1:1 rgba] + +Filter: Parsed_scale_2 (scale) + in 0: default ← Parsed_format_1.0:default [320x240 1:1 rgba] + out 0: default → Parsed_format_3.0:default [320x240 1:1 yuva444p] + +Filter: Parsed_format_3 (format) + in 0: default ← Parsed_scale_2.0:default [320x240 1:1 yuva444p] + out 0: default → out_0_0.0:default [320x240 1:1 yuva444p] + +Filter: out_0_0 (buffersink) + in 0: default ← Parsed_format_3.0:default [320x240 1:1 yuva444p] +