From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0C2F2496B0 for ; Sat, 17 Feb 2024 21:13:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B8EE68D2EB; Sat, 17 Feb 2024 23:13:05 +0200 (EET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02olkn2090.outbound.protection.outlook.com [40.92.48.90]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7CB2A68D247 for ; Sat, 17 Feb 2024 23:12:58 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=inYnJCcIIyHwdJ17O9aCC7KMCH012k9EXGsKkIYiYi+hQ8ZnWZKZ/3T86Y0NlmWPKhdoMx7Kii+mhtZkLT30LyiORNCHMlfgsfLv/F8iFkRkcYTEo5R1sNNf+1JVSxB8CzR4Wp/t6mH5G4wPkMzSZlOjofqrcESy5tly03Ho732j5Iql+T3IV7RvS4sDLmLFncv7DYLfB4LCe6sXgACcY7D1p8VCB84HRM+Jw7Gh0u0+Jb74a+c7Y3n4vPUFRSxpvc1VZf3UGpkwH3Ss6aakMPIaJ8UqejRHnsKdlT4lByXlbbrPTS9pS4wUWVxFUV6yWUYsWf8ycmsW1NpsjZ/N6A== 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=JTQ0HQUIlvmzZj0/MmZwAK7GzfwYommP2bhqZakVnjc=; b=U4DHp/DImD0H+vZ1gR7LzTMAuKfP/Dv4IKOEqX7HGqrxL1TsEOdiiKymnLzFOm7d7zL1bKDYvOqeQzOvztYOG76Ra0Mp3K6ZmjMzVoj8O3JafrUosmfBEIM/1YCeX7ZNdS/75+3LvpcAL0EqRUdubra+ef/eLR1nr5Sh6nRc9XlrQmIO6C3cgIbIO+mKulcmFPmtUUoQtxRmMBSxPspF8I8tQlfWIJE2W7HbVC9EtX3ep9hmsGMnXDcdKgH7pHQ4ufCeLpZfm3frGh58EUYZDLHcYxQNImS9wnTMOzXgkcAlJ37PahIK3RkXYMJnl7ilqGEHraHAnvefmGEIE4Mpdg== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JTQ0HQUIlvmzZj0/MmZwAK7GzfwYommP2bhqZakVnjc=; b=i7N3dEnjYVG5qok9gYCPo9P0+ahRQYIS4/q1sR/yA0FMgo9sVPmvg9cOf95BJ96jIveAtsFG/17+vUR72SKcHWgtO7Dej3JouyrI/j4kSDR94h1XtUr8kOfS+WuroV6tPT4s0VMAwvmw9V5lM36/oSEDJ4lMTorDqQ9ysObVbwUNS99nNhq5s24Jq0znxVMOWIMHRvfuoTDN18g14shc8NzpXdJfNnAoxjpQ2pPYHFBBE3I/fOPlJE2eTX2dR08jtSSM/402JvTN3Ai4jWBlZmbfKnB8yjA1rBFo9JUm8aboavG8OfjB+Jjdvg2t4Q7hGSmE3aCR8HSBn8TlrCAwrg== Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) by AM8P250MB0041.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:3d8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.32; Sat, 17 Feb 2024 21:12:56 +0000 Received: from GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504]) by GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM ([fe80::ffe3:46c:6214:2504%6]) with mapi id 15.20.7292.026; Sat, 17 Feb 2024 21:12:56 +0000 Message-ID: Date: Sat, 17 Feb 2024 22:14:51 +0100 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: Content-Language: en-US From: Andreas Rheinhardt In-Reply-To: X-TMN: [y1p8/KRJSMmmJANopWbov4pkrSDHvI6/gR4kTk6B8c4=] X-ClientProxiedBy: ZR0P278CA0134.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:40::13) To GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:109::7) X-Microsoft-Original-Message-ID: <903562ab-15b5-4c69-b37d-11d3c3c2ae1b@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0063:EE_|AM8P250MB0041:EE_ X-MS-Office365-Filtering-Correlation-Id: 08d158c8-0aaa-4714-93df-08dc2ffd35ef X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: anDtkSILWdo1ltpUv0I5BMwyJ3oLw/+1XOnt6ZT9779SmPZ4FYjrz+82Ha9O8YLMuvE7TuMBgL7wTe2uNwE430jvdV/9HezDsWPx+C6LaxXZHsPWcruhl+60ANmra43/MzUZ+ZdNWFNtfTY9jQhq+2fumePuhGKMbakQPfgVw4QoRHKoe5whU86tvpVbH/NHxmiF4jyFgADN1OS87Z6N5Uj1I5bG/PM6+4TDAsmBdc5W0Zc8rj3YVZwunQo8MsT3mX6ooLc+29fHGGHU1v3bJ4O/yfzHv+q1W4amTvKTMp1StlvBtenRft1M9SUhZeK0n/xvFVf6xn71hJcWvXIBOk6nFgEb9rUv6H+teHJJ6DF9gR4IGuOQ+E2OB2ODKzsr9rttz9mYPzJv9Xab3JycG/qBNL2U9DWBB+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S9aV3psZ21iR0JhUFJLWGlJa0Rzcy9OSlR5?= =?utf-8?B?dWdwL0VXVHBXMUFBcXBXSlJ3MlJPM3JDSE9KekdCMkcyTDIwMHl1UHIxbWhB?= =?utf-8?B?dHFBcjVuV2dPRnQ2b3pPVkRoTWwvR1N5YWNVMHFEaG1HeUdrQkxnZFNBPT0=?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08d158c8-0aaa-4714-93df-08dc2ffd35ef X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0063.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2024 21:12:55.9971 (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: AM8P250MB0041 Subject: Re: [FFmpeg-devel] [PATCH 1/8] avfilter/avfilter: Avoid allocation for AVFilterInternal 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Andreas Rheinhardt: > To do this, allocate AVFilterInternal jointly with AVFilterContext > and rename it to FFFilterContext in the process (similarly to > AVStream/FFStream). > The AVFilterInternal* will be removed from AVFilterContext > on the next major bump. > > Signed-off-by: Andreas Rheinhardt > --- > Several of these patches are from the bump patchset; I have just > removed the removal of the internal-pointers, so that this could > be applied at any time. > > libavfilter/avfilter.c | 22 ++++++++++------------ > libavfilter/graphparser.c | 2 +- > libavfilter/internal.h | 16 +++++++++++++--- > 3 files changed, 24 insertions(+), 16 deletions(-) > > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c > index 9fe249f3f9..2d935cf576 100644 > --- a/libavfilter/avfilter.c > +++ b/libavfilter/avfilter.c > @@ -159,7 +159,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, > src->outputs[srcpad] || dst->inputs[dstpad]) > return AVERROR(EINVAL); > > - if (!src->internal->initialized || !dst->internal->initialized) { > + if (!fffilterctx(src)->initialized || !fffilterctx(dst)->initialized) { > av_log(src, AV_LOG_ERROR, "Filters must be initialized before linking.\n"); > return AVERROR(EINVAL); > } > @@ -668,15 +668,17 @@ static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, voi > > AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) > { > + FFFilterContext *ctx; > AVFilterContext *ret; > int preinited = 0; > > if (!filter) > return NULL; > > - ret = av_mallocz(sizeof(AVFilterContext)); > - if (!ret) > + ctx = av_mallocz(sizeof(*ctx)); > + if (!ctx) > return NULL; > + ret = &ctx->p; > > ret->av_class = &avfilter_class; > ret->filter = filter; > @@ -698,10 +700,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) > av_opt_set_defaults(ret->priv); > } > > - ret->internal = av_mallocz(sizeof(*ret->internal)); > - if (!ret->internal) > - goto err; > - ret->internal->execute = default_execute; > + ctx->execute = default_execute; > > ret->nb_inputs = filter->nb_inputs; > if (ret->nb_inputs ) { > @@ -735,7 +734,6 @@ err: > av_freep(&ret->output_pads); > ret->nb_outputs = 0; > av_freep(&ret->priv); > - av_freep(&ret->internal); > av_free(ret); > return NULL; > } > @@ -807,7 +805,6 @@ void avfilter_free(AVFilterContext *filter) > av_expr_free(filter->enable); > filter->enable = NULL; > av_freep(&filter->var_values); > - av_freep(&filter->internal); > av_free(filter); > } > > @@ -891,9 +888,10 @@ int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, > > int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) > { > + FFFilterContext *ctxi = fffilterctx(ctx); > int ret = 0; > > - if (ctx->internal->initialized) { > + if (ctxi->initialized) { > av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n"); > return AVERROR(EINVAL); > } > @@ -908,7 +906,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) > ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE && > ctx->graph->internal->thread_execute) { > ctx->thread_type = AVFILTER_THREAD_SLICE; > - ctx->internal->execute = ctx->graph->internal->thread_execute; > + ctxi->execute = ctx->graph->internal->thread_execute; > } else { > ctx->thread_type = 0; > } > @@ -924,7 +922,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) > return ret; > } > > - ctx->internal->initialized = 1; > + ctxi->initialized = 1; > > return 0; > } > diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c > index 96ef6b15bf..229e647c0a 100644 > --- a/libavfilter/graphparser.c > +++ b/libavfilter/graphparser.c > @@ -626,7 +626,7 @@ int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags) > > if (p->filter_name) > return fail_creation_pending(seg, p->filter_name, __func__); > - if (!p->filter || p->filter->internal->initialized) > + if (!p->filter || fffilterctx(p->filter)->initialized) > continue; > > ret = avfilter_init_dict(p->filter, NULL); > diff --git a/libavfilter/internal.h b/libavfilter/internal.h > index a6cdf9994c..3d46923cad 100644 > --- a/libavfilter/internal.h > +++ b/libavfilter/internal.h > @@ -133,18 +133,28 @@ struct AVFilterGraphInternal { > FFFrameQueueGlobal frame_queues; > }; > > -struct AVFilterInternal { > +typedef struct FFFilterContext { > + /** > + * The public AVFilterContext. See avfilter.h for it. > + */ > + AVFilterContext p; > + > avfilter_execute_func *execute; > > // 1 when avfilter_init_*() was successfully called on this filter > // 0 otherwise > int initialized; > -}; > +} FFFilterContext; > + > +static inline FFFilterContext *fffilterctx(AVFilterContext *ctx) > +{ > + return (FFFilterContext*)ctx; > +} > > static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, > void *arg, int *ret, int nb_jobs) > { > - return ctx->internal->execute(ctx, func, arg, ret, nb_jobs); > + return fffilterctx(ctx)->execute(ctx, func, arg, ret, nb_jobs); > } > > enum FilterFormatsState { Will apply this patchset tomorrow with the change that link_internal.h will be merged into avfilter_internal.h unless there are objections. - Andreas _______________________________________________ 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".