From patchwork Wed Oct 13 04:49:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 31094 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp5559476ioa; Tue, 12 Oct 2021 21:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUz40kwB8A4DXY7yyngfGl9TUitZoBQ8n+tfAr4liZOn3m62QflpivP/br7gRIQ3PA8b89 X-Received: by 2002:a50:c006:: with SMTP id r6mr6289738edb.289.1634100610361; Tue, 12 Oct 2021 21:50:10 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id di4si25379128ejc.505.2021.10.12.21.50.09; Tue, 12 Oct 2021 21:50:10 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@hotmail.com header.s=selector1 header.b=Iuga2HCy; arc=fail (body hash mismatch); 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hotmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3370268A808; Wed, 13 Oct 2021 07:50:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2082.outbound.protection.outlook.com [40.92.21.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8BD856800D9 for ; Wed, 13 Oct 2021 07:49:59 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eGq9YvMmZ5dMCxX5G0008h40H7WrBQZgshyYa/KlJUBKvDlUOapDn26N6LCctlXPS8lnZQSqJJP2m7PT3Ho2MLsUhnEJMnGSHxxk6QXqXEIAus4QsExZF/hvx5sh1re+R0zo1ze/DA+nWp8b046Lnpi+6eWkZ2vWTVYGak+5VEB6NMHtR5Fifvj/dgooeTA+BVFt6SvVObr4KBSLN4W52VPK9SvWCvWcjwsItlgKUADhvlAEnX06U03l7jfd6abhhxUiltdZ8q4uEBfWNIfWgSlFEOBZG867tB5MFRJQgGv2/OGaI2qUiEKjcR7I/Fj8qSWuKKFOTa26YEkYhIMTEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oZog/7dOOCrR5BvrbVINUtNfLXhRq8UkjlBvHDfBtWU=; b=NyZ4VTa0pwAUwOoNczIBWddGQ50z2Z/bZeabHmm3dVygQEsVKWtECIIf2vwhQwrB3N7VoFZoOfUcI9Yznp1nk+AZeVDRp8RUQ58psi1SwlOB+8FwsyLpbOPLabXKHK4lXaG6KJ+/RZbA4uMoLSnk0uOdzUBwGp/hRi2Bbw28zFg5vuDRKJPTFUvhvCvVYjsWCdXCKZIQmS5JGhISIMJbQ4IR5ASFoWiGoEA/YxAiCoLYI5wUHSYFqUsls3bkOJ9V78pDbe7tepAJDZOAHroo8jSrfjF/XJd2SbKGPJDTWDweafzs3N6KY5OzhM8fZh3OiM2fNZBN3rBv6vUmHgyhyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oZog/7dOOCrR5BvrbVINUtNfLXhRq8UkjlBvHDfBtWU=; b=Iuga2HCy0E9WTWZ9nWMtLc+sm0/tq2D7RiiLrXhoGmXsiKzSA6qrEoylU9R/Exnzw3i4Zhpa4O5O7WW7N2XSIEmQxjMijWFuqFDDD37Zy3Xdbu6O5LjVqG1OYLOqEFBtSp4BqtiR3ZHkcC5PIY7HUXfWWXirev88XZWiJ7Uz8O8fum6UfKcRttJZTUZQcfxn/exUbQiLpakWUMb4KV6Rl3v370SDJOJiCy7PntZ+xHT4RBbj6GIDVexQfXbZVmaqNCTqoQWogctriY633z79HQnp6RvjsY5v7iBS+t83MVbS11uv6oPAZS6TmQ+4jDHwAnGT2dZbUa9UcOIHWdK+QQ== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB6205.namprd04.prod.outlook.com (2603:10b6:208:d5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Wed, 13 Oct 2021 04:49:56 +0000 Received: from MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb]) by MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb%5]) with mapi id 15.20.4587.026; Wed, 13 Oct 2021 04:49:56 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH 1/5] avfilter/avfilter: Add avfilter_alloc() and avfilter_query_formats() for initializing filters without a graph Thread-Index: AQG/IMss9hwT72uYI1H8LXEEqR1CoQGXeu8g Date: Wed, 13 Oct 2021 04:49:55 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [4hT6Atp/zzrBa99RoMVLiYYUxavUk6q4] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ad8245e9-5ebf-46dc-54e3-08d98e04e73b x-ms-traffictypediagnostic: MN2PR04MB6205: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9AEg4HuWhUDY6FjVGZnud7mhaMFog2PbcsnNy4/zAs6P0MwtEYRTWsZ/WqHZ/O3Ef2jrq62KRtHJhPa5V+StkwCUiAdO9EtP/anOfkDp7OCn4jGeuMZ7moF8EVh5JVNuCU2BsAJfoOm5sps4KwTCK4uGZhGdpZjTKRBOLa55qLCbD1xiRrYe5W3pvUuA10JuSowcCyv3TY6baitaBCscS5iuaW/njNQqqD+Gi175+gvTsn7JLXjt8XhssFV3a9HGD6PrAqIsA01T5IaG4tcoIXea73PKDrdDfo92El3+paXUMLMX86qPPMPzxHCiM46lUIHwR27QI7zminkon6MTBBAFURz3K7WY5EDMblSH7kE6/G6chvXC48P4vOv5IXqR2jgw3nTY3WiDzGebfONYx/EQKeudqJlAIduzLNlAYgcWwAdJZxgPOIJYijiFNUIh x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: 5fbIm6ij84LkmOtTiofLVM5AfiyUxlyaoCEX2svxRsECZ9c04go85UxJ7sy11/ZW/sCcLNRraWj4QMGJZS3ufvq0ZYQNhPJyTx9KevarAxMWoqsWnsE/kHUfhki6SUFMrmnAT1AIu4tmpHQdROIHnA== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-529c7.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB5981.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: ad8245e9-5ebf-46dc-54e3-08d98e04e73b X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Oct 2021 04:49:55.8985 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6205 Subject: [FFmpeg-devel] [PATCH 1/5] avfilter/avfilter: Add avfilter_alloc() and avfilter_query_formats() for initializing filters without a graph 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: RFVA3vzlu/Rb The purpose of these additions is for being able to programatically retrieve the supported formats of a filter for each input and output without adding the filter to a graph and creating connections. Signed-off-by: softworkz --- doc/APIchanges | 3 +++ libavfilter/avfilter.c | 4 ++-- libavfilter/avfilter.h | 22 ++++++++++++++++++++++ libavfilter/avfiltergraph.c | 18 ++++++++++++++---- libavfilter/version.h | 2 +- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7b267a79ac..903de43365 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-10-12 - xxxxxxxxxx - lavf 8.13.100 - avfilter.h + Add avfilter_alloc() and avfilter_query_formats(). + 2021-09-21 - xxxxxxxxxx - lavu 57.7.100 - pixfmt.h Add AV_PIX_FMT_X2BGR10. diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 7362bcdab5..645af2cb11 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -769,12 +769,12 @@ void avfilter_free(AVFilterContext *filter) for (i = 0; i < filter->nb_inputs; i++) { free_link(filter->inputs[i]); - if (filter->input_pads[i].flags & AVFILTERPAD_FLAG_FREE_NAME) + if (filter->input_pads && filter->input_pads[i].flags & AVFILTERPAD_FLAG_FREE_NAME) av_freep(&filter->input_pads[i].name); } for (i = 0; i < filter->nb_outputs; i++) { free_link(filter->outputs[i]); - if (filter->output_pads[i].flags & AVFILTERPAD_FLAG_FREE_NAME) + if (filter->output_pads && filter->output_pads[i].flags & AVFILTERPAD_FLAG_FREE_NAME) av_freep(&filter->output_pads[i].name); } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index f7208754a7..24119993d6 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -911,6 +911,28 @@ typedef struct AVFilterGraph { unsigned disable_auto_convert; } AVFilterGraph; +/** + * Allocate a new filter context and return it. + * + * @param filter what filter to create an instance of + * @param inst_name name to give to the new filter context + * + * @return newly created filter context or NULL on failure + * + * @note for adding a filter to a filtergraph, use + * avfilter_graph_alloc_filter() instead. + */ +AVFilterContext *avfilter_alloc(const AVFilter *filter, const char *inst_name); + +/** + * Query the formats of a filter. + * + * @param filter the filter context + * + * @return 0 on success + */ +int avfilter_query_formats(AVFilterContext *filter); + /** * Allocate a filter graph. * diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index b8b432e98b..64379782fc 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -81,6 +81,11 @@ int ff_graph_thread_init(AVFilterGraph *graph) } #endif +AVFilterContext *avfilter_alloc(const AVFilter *filter, const char *inst_name) +{ + return ff_filter_alloc(filter, inst_name); +} + AVFilterGraph *avfilter_graph_alloc(void) { AVFilterGraph *ret = av_mallocz(sizeof(*ret)); @@ -395,6 +400,14 @@ static int formats_declared(AVFilterContext *f) return 1; } +int avfilter_query_formats(AVFilterContext *filter) +{ + if (filter->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) + return filter_query_formats(filter); + + return ff_default_query_formats(filter); +} + /** * Perform one round of query_formats() and merging formats lists on the * filter graph. @@ -418,10 +431,7 @@ static int query_formats(AVFilterGraph *graph, void *log_ctx) AVFilterContext *f = graph->filters[i]; if (formats_declared(f)) continue; - if (f->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) - ret = filter_query_formats(f); - else - ret = ff_default_query_formats(f); + ret = avfilter_query_formats(f); if (ret < 0 && ret != AVERROR(EAGAIN)) return ret; /* note: EAGAIN could indicate a partial success, not counted yet */ diff --git a/libavfilter/version.h b/libavfilter/version.h index e4c25b9225..dca5aacb45 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,7 +30,7 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 8 -#define LIBAVFILTER_VERSION_MINOR 12 +#define LIBAVFILTER_VERSION_MINOR 13 #define LIBAVFILTER_VERSION_MICRO 100