From patchwork Wed Aug 11 01:17:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29413 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:8e8b:0:0:0:0:0 with SMTP id q133csp956047iod; Tue, 10 Aug 2021 18:18:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpWtPtdLS22UhK61JWGg2KMR7DFtS+0eIEWFBsI+g+LRruCE6ymCxDLAYcr72eP0hqKGrY X-Received: by 2002:a05:6402:1add:: with SMTP id ba29mr8301849edb.145.1628644737839; Tue, 10 Aug 2021 18:18:57 -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 h8si2183650ejj.750.2021.08.10.18.18.57; Tue, 10 Aug 2021 18:18:57 -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=@outlook.com header.s=selector1 header.b="jug/AwhJ"; 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D5B4B68A47F; Wed, 11 Aug 2021 04:18:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066053.outbound.protection.outlook.com [40.92.66.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2408168A404 for ; Wed, 11 Aug 2021 04:18:32 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CRKLg9OFHG3wAU2tSSM+6FwwjSSBnN5gQ8NY5TwNqjcsktq3HmeUPk/t9lPVarEtaKiQ0oKNZeZ3lfDd/3/wZ8fHLHUqtGWneIiLyBw5+XtzXkkzaePaGBxOe4QxQvzlgB6Y4imIf7faN6k4UWoeYSGNC+ubbUZEkJsMnHXxZKWvNoNsle0XUNfSmd7Y4OwM8PVzYSGwtHgHF3FTQcRv/5Q18SQyTXe9JlhFRhCNQTa9Xn2vogpkEwVqz1d2+GPoDGtoMb0qxR26NhtvWNxMtKCW0f49dzRrkKwW8LDbpyShrbRXinmdB+OBPoyrFqAOcgyXK1URe136grIXNc6WLQ== 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-SenderADCheck; bh=7Nx1g5QeIwJjY9r92E+1KsqwapwMzbm7hznfg6PvMQk=; b=PXZDQmHLkufmjisNqS9H2l6PY3GjeqT1zvs7TRRIaY/9e63QYB7G11TZXp2hpra4xMqNlFo78Ortu2MU+EZMtWEijvigpp+Kc2XtAPVHzzP4CC4P2OExDHsA3kYSlQSEPq+LDNZcE0lICIrgs4CUkyXuYb9sxHpGA+B4KWCs4oouDvbf0Vit7r3gsErtpTPqC1p7QCUXcagYuT6qEcK0gOcWONXngPHxUJQJFhwSxcuPBkh5mOv16UO6eK+CAgjR3Wue9crKGC4aXdkoJy8UGR6oKnSvEECEiKdOwq2y+2Cw7N7cWuNdDZv/sbJJpEFiKQz4V9F4fc2YynnWATGugw== 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=7Nx1g5QeIwJjY9r92E+1KsqwapwMzbm7hznfg6PvMQk=; b=jug/AwhJDMum70HVONGYEp+0CrajfPhyeYyj++dmkiPp06xK3zz4ql9hRdLZ3vBKU+CHUvepNcDFEWsVrB3kk17e/ii1yYehuttBC1pJGlNk3K8jD56WFjGWaF02BB3ejEiZikJSkb4Xa8U8x9NZ4Z9OMrbIwhUdZCaF0J4VMPoZbQJnu9N/jqRJWqxOvjqJu9tRWLoAuc/6GHY/epNOngDNFp8omLqxIKoduFxfT3iZ+d/1E2E1/t/jJQvgKVkS32+WPKanYkbzL75/UEqDPV8zNN94W/8BWm7JGxUrZGWYWX3Px0Un/wMLD071dkhDMSnJWL7jmVd7Xt6QiBiU2w== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4613.eurprd03.prod.outlook.com (2603:10a6:20b:11::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.21; Wed, 11 Aug 2021 01:18:31 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ded:bace:bc7:e91d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ded:bace:bc7:e91d%3]) with mapi id 15.20.4394.023; Wed, 11 Aug 2021 01:18:30 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Aug 2021 03:17:51 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [4REfFXG8wls2k7qDK0E6qUeW2ARmzNMz] X-ClientProxiedBy: FR3P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::13) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210811011753.739659-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.95.102) by FR3P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.5 via Frontend Transport; Wed, 11 Aug 2021 01:18:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac38091e-5248-4b82-8437-08d95c65e8d7 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiT4+P6zBac8zxhOSuRwKn5lWpt03MHkLQa13aJNDWF4qPFOP8kBO3RQjPVOeJ+FYi+1tvd177C8TbBE5jHX6+2cNVMx0/n8B+7o8Ig5L30goyDDm2MJAlkVaZkwNL/rC/z/5cUcKMS8L5IjAGFxiHvGNSlXGbcUZ3Id4RBHueMklBIHDDbylocXp6JGWELVQdRnhnNOfMXZT6dj7TcyH0UIWrJjlKZA9UU6JTCqgj4d+o+D1t38LqtgWu7Smp64b6hN/nFLCd7SYw9gXxoSy1OFC06/ObEMj63sFScJp2ROCM4qP/Q5HPk5YJqMMzfU9kBfxHRx6vkIDkJ7CPytFmNQc6ow0baODEBq8PP8JIWfHSIZ7Aa1OSBVRRTCMXaFKqUfUEvpV4y+lPfw/ZGFmInh/ojyh2u+3P4L9FsNsZMqcBD61x1DHxxhmXTgwzn6ZaChSJ/BB+QO3qmvPjrqHAM19wbv5twEBd+1EDZ4FKOZLfH90J3dIkKNKmyeAHy6kPC5CxRSof0DIJ7606pzwpocYb5HA0N6HGGpZTri0wPxkxLsp9uBJs0WWKV0MwL6o29FIc3kkOoHmibt/z3hv3aJoMoZxvX3os8FOb76o5hqsCnuwbPWY+emCXP+yZggEtW5MqmDHGwwSZ+UBd/67WFR0MCpPHHl9V0WGjJxiGdkWJR1bX34TciiEqL33KbYcYayX47h2SPFs6oUxfWxcvUg/yn9pkqzk9BtqU8HsSMKRuGwdbswW/zjql/wNGpvxVU= X-MS-TrafficTypeDiagnostic: AM6PR03MB4613: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NThxST2A8puFr9eGqCXdFFTJwSf/unNoBSRm3UXvP4LpeNqtsFmsYOT376vNtnWmSp+dq2n/L2PaLbODz/qc2cVhk1p9uJXGn7Kjn22+Vu3dmSMs9iz/JM1CGwYBI0rD2PQc2QuvhS2f/QCR8Txb+ho/V8JXTJtZSbLC+SBajL6rmA0HLUNu37RdZ7MWpJ7IKMvEmvJ0tDUVCfv8Utr43QSWSWiqV/3WvvZsO01jMxItOKZbWj3iYCEWcAv9GzNNyVfdmJkOEpqhWLro3yaXxKMLvkslx1cn4X6Dq02fRqTuLSMyLez4xqU2iX8fCIqoNJfBdRIZb0DXXnwv8DGdycuRaApY95sF94IUncZJ7LJ5I+2SGcUvGgm/7RuC0GhbQHVBBWXmySxovbBk4RpaiiKhOsSbRYrJRiEwCPhVU09PW4KpcYgwUWYnYl5+YdtR X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2wd0x8v68XRhUDXBzRTo97dijcjAkAxfB3GExXXcAPAox1qEYZLaEArBGdTEn4/3hImFYh64wt3ZYnFKh/gt6L+JF+5HRmxjjqtGeOyonAnHsCAlM1UHLAH7to6PEn9AXeaSe8S1LVVNkFomkKo7Rw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac38091e-5248-4b82-8437-08d95c65e8d7 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2021 01:18:21.9298 (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: AM6PR03MB4613 Subject: [FFmpeg-devel] [PATCH 08/10] avfilter: Avoid allocation of 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BeyGvbpPRkyB This can be achieved by allocating it together with AVFilterContext, with the public AVFilterContext as first element in the new structure. Given that said structure is now more than just the internal, it has been renamed to FFFilterContext. Accessing it is not type-safe, so this unsafety has been confined to a single function. This break ABI due to the removal of the AVFilterContext.internal pointer. Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 15 ++++++--------- libavfilter/avfilter.h | 7 ------- libavfilter/internal.h | 12 +++++++++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 7e48ff14c5..6925d99659 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -623,14 +623,16 @@ static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, voi AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) { AVFilterContext *ret; + FFFilterContext *ctx; 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->pub; ret->av_class = &avfilter_class; ret->filter = filter; @@ -652,10 +654,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 = avfilter_pad_count(filter->inputs); if (ret->nb_inputs ) { @@ -695,7 +694,6 @@ err: av_freep(&ret->priv); } av_opt_free(ret); - av_freep(&ret->internal); av_free(ret); return NULL; } @@ -759,7 +757,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); } @@ -870,7 +867,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE && filtergraph(ctx->graph)->thread_execute) { ctx->thread_type = AVFILTER_THREAD_SLICE; - ctx->internal->execute = filtergraph(ctx->graph)->thread_execute; + filtercontext(ctx)->execute = filtergraph(ctx->graph)->thread_execute; } else { ctx->thread_type = 0; } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 4436eb7d2d..26a849f955 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -327,8 +327,6 @@ typedef struct AVFilter { */ #define AVFILTER_THREAD_SLICE (1 << 0) -typedef struct AVFilterInternal AVFilterInternal; - /** An instance of a filter */ struct AVFilterContext { const AVClass *av_class; ///< needed for av_log() and filters common options @@ -367,11 +365,6 @@ struct AVFilterContext { */ int thread_type; - /** - * An opaque struct for libavfilter internal use. - */ - AVFilterInternal *internal; - struct AVFilterCommand *command_queue; char *enable_str; ///< enable expression string diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 48a911f082..040ce6dee8 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -134,14 +134,20 @@ static av_always_inline FFFilterGraph *filtergraph(AVFilterGraph *graph) return (FFFilterGraph*)graph; } -struct AVFilterInternal { +typedef struct FFFilterContext { + AVFilterContext pub; avfilter_execute_func *execute; -}; +} FFFilterContext; + +static av_always_inline FFFilterContext *filtercontext(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 filtercontext(ctx)->execute(ctx, func, arg, ret, nb_jobs); } /**