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 D47A648669 for ; Wed, 14 Feb 2024 17:22:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C8BF68D1F6; Wed, 14 Feb 2024 19:22:28 +0200 (EET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2037.outbound.protection.outlook.com [40.92.89.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 10DE268D1CC for ; Wed, 14 Feb 2024 19:22:21 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TP29ZoFHlmzlXII6YeVPFtQl/wZWsERq1zeQX3Bf/lDfuZG+NZpF+/oStlikhOosA3SvrY6AD5VXG0OJdlq0ff3OiN8N9vMWGKBg3S4K1wrixtHlRMtWM7Bjx38YKhtOGnKUt7ibNcL8fcN9gon37uT6fV0rknQTSr+/kx+xkX0NySyA6K1egM3bp0j2CvTKG4N0BIlxv+3sL79rCJ6PRWXL8StcEsZ69C2T+kic/X+TpZAYaIgIh/loLw9aJ//E8hIAwuDys7K69oOqsuu9vJ4SWHQILOJE6IDTN9jaLEnlELqRO/55Q84PgjQ8549xIJHq/XsPNwuUWfy9Bu+qOg== 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=MB4lMFYfZCmDqoU88TjmDfuhL44667jA6uEKLvOM5IQ=; b=NKf6AITlVz0UFTjf6wcV+vbn+pWj61SZFEJYLH/KXHRtDVLnwv8V0xqyRiMJ/HoV0WdaWPkS24bP8AMyMPfL6Nn8BgmeKbIpE547YOmoEg9T7LhE770E0zwV6xyx3d0i/rn/1QiZRz2P888bq1ONLdRkUyW1qn59pi2BGRD8b3U3vknGKEE8IguasnPlsS6LwB54J6M3oonf18HlXTF5VXaRou3C3PTVsze+GIInypsm0AzOw6Q8J/KwnOXESzd/SXunYvLedpS+IkjQrZaOWIrb94qiW0vCGi8h2/wemsJH3dJ3LbgCq74/2jz3PZJSIwPaX5+jwcfj8b7+MDedpQ== 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=MB4lMFYfZCmDqoU88TjmDfuhL44667jA6uEKLvOM5IQ=; b=mZW8uE5tw8jm9e8J1TXvKtlQ0KvxwdAArwVTll03bWQ036JR8HdjRY5wM9iVbSKDhsXI72PEju3PpzSDYIZfjGV15omInDAqwcnfX03n5xx9yOpNtDWS8CurLtzEoM6Dczn9xT7+L8zhefSYK5ibrTMdsEWZb/ixAp9qvU8LNmzqxW+tHmZ89gADV5lpJMVaqQKBF2KGXPWnjyReOEpMWoN2rQBB8E8z2lqKLVftolS094KuRU7Fmux37XPVswJOQ/qsMVPw+QI+/kUfOxC6Gz2w0D8V1MpYC820L25WzJPtwh/H35hgmrN3IcEpHTICeqCQbbuEk4DuoiZNVCg2/g== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by DU2P250MB0320.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:27d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.39; Wed, 14 Feb 2024 17:22:18 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7270.036; Wed, 14 Feb 2024 17:22:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Feb 2024 18:24:01 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [0Ck2Gxierfq4ChEKfSAYqUI5fudQKSGaFc8DILVlUxE=] X-ClientProxiedBy: ZR2P278CA0052.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:53::16) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240214172408.1099356-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|DU2P250MB0320:EE_ X-MS-Office365-Filtering-Correlation-Id: 230c9584-8f0b-4848-bc4b-08dc2d817f1e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R1B3IIP5NT4T+rutAV3+dojsnF6iIEXpEZS6o73Ehtv2kK8TwI/aVRpCU/+6jTjGV/uN2ny6pt2R9u8OkdsDz/kLE1L6qHOIhahe7aSZVWWscoRDneRVyq7Lu82de5Q4K4IpSv6xqlns1jqORZN8ej8/gHLCjQyWzXnRvD2zYDOwRU3cnMB1cBS6TWb00i9nDtT5nsf/LwutnJtHGvuSwlsE7j1sGrFb8nuOxGSVMvUy1sFdTmmoHnvot3d+Ti24BuJJVwP9PG/CjIVUBifSjFeAJ9wR5uVv39Mr0i4qKiBn2+MSdZrSgTy+SeS7g0U1idzj0d25bgx1PKV+buHPQnDkzM1ItPxa0SGWRbr8eMrpsne6j8k/UhYJjizHfouaDuF1dxyTdhV/+TqkQ2h36fSDRDC+pEgBX3G381/riqQAnOlgArqDhMlkfof989Giq0s4LtZmYa20+XwytI38vRPHJNqiKAZYY47OS0CTb4g5kRmww3i+WZqK7CvFjjkw1/kAx+JqsR+MefBErqS2B2cPIiQLsJ8CebXaNOr5/J0fOpi7Wl/Nr1hdsCtDjwa1tidbgxcKa1+xI3rLQIaHuEldT+6gFKA+PmldxCLDut+uqP7oPgYel73kPWv4+BQs X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tOPwdhryv73x/rasU7BigsJP6lb9pGGfqtYjupv1hSDV1DnbgUCwzmUTwGdz?= =?us-ascii?Q?DdhGr/N/MzTT3ayNkGMGPT2kgNGlNou9TL8TvqMOAsIHCmurB+JWqYs+TY8b?= =?us-ascii?Q?zMTWzZIR5Ug+OASgOHSZ2jy6KFwy0EZFhiVS2PjYuRVageMf1NPtB/sJtNXk?= =?us-ascii?Q?Qs6DSvVknXHCvFmp3l6s8SxtJ7Hf0ffZ5hLHCfeeuc3H6zHJMPhTDex1jNQ+?= =?us-ascii?Q?HB+BAQvlosPs+S8nZ6vih6kdm+SvYsZNoXzn+arDLppzex4AJwO+7MtKFec0?= =?us-ascii?Q?zdckk5DIitg9PzF7ORgTOktq7KR10aJChAiLHw0XGFemYvNxrMgZaBw4Ode/?= =?us-ascii?Q?FlPsydmXcI4LKnBeylJpmp4simHvUOpbO+qwk5FlPUUqzEdnzuu5sasz2xON?= =?us-ascii?Q?P/owlC9aUsY+7S7QcM0jS2SXxj2pXjFDrNHt/VNHAaU6OF3YzFq60HJpOv2n?= =?us-ascii?Q?2Hm2Z9nu4msP67IYTBRGEcchvku+tkjNld01bVlTcpEtbcM/9UyYNBmUFTN4?= =?us-ascii?Q?2qpSGvsivwFsHY5VvLXSsGg8KYVU4z2U2bQIj9f8tn2srKWv58Mj3OV5trKA?= =?us-ascii?Q?LeCtYeQW+S40b0B/xl8uB8DxIxHuKsPXXQuQw1VkHAJQA0WMyEeRWKNTZKF/?= =?us-ascii?Q?41ph+ubXU+6cyGGNFOXsS3S07xiPEh/44RLEn0p7SrCpgBLrglsLYQLCEbcU?= =?us-ascii?Q?j9AZlRgcbMjGzj4ETX5J/ytor4VdQSfftGCUQ6Sd6K4wFRSzdShoyRVytzfr?= =?us-ascii?Q?QTMF/0hgqsmFNzONg5mNpe/z8wnrUoaYPE3ktHTdUmZPNd7pa11VGA0Qb86+?= =?us-ascii?Q?1eiCk1ZJEoXsijMJsvLEbMnNP+7b42mZAuZNJ3y+k103uHBSe0Y9DNaUyMTf?= =?us-ascii?Q?oYY8bS4xOFIp2exYHkEzZU/5xp2PxNYEqedFB1Ou0bLFHBPQPeP5CzwSvpuZ?= =?us-ascii?Q?s2ekZQ68V2PyNiYC7J//S45aQ9CaPE/ZHLVtH0b+LiZXjKwKzJF0wH0aogzt?= =?us-ascii?Q?wrK3Nyqpn2OSqr+19LmtmTvDmSHHdOW6p4BuU01HlSFEPDKkjEfd63ZBdQwl?= =?us-ascii?Q?iBQuuFjKGbz8T+YMjtZ4s2CSDdJKRBQsM7zIdJsE23cRpdFB1fDUn313287L?= =?us-ascii?Q?j44bVeGT3Mqs8qehjsLX8DRhoCY9rtkK2E0jjT01THqV/SyJIrFws7OWNy2B?= =?us-ascii?Q?2UGKaRcXC1d5LKOq/PoLzrEfTUN46md/F04SfqZYPnU5/yNVPyWbN/LIc6KT?= =?us-ascii?Q?IbcjbxaWL+gZRUh6w/+RtAokZJEHaJq9XUGyOilB6g=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 230c9584-8f0b-4848-bc4b-08dc2d817f1e X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2024 17:22:18.9266 (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: DU2P250MB0320 Subject: [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 Cc: Andreas Rheinhardt 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: 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 { -- 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".