From patchwork Mon Nov 21 00:24:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39362 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp1815599pzb; Sun, 20 Nov 2022 16:24:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf6m4fCMtjbi4xns4rijlflrHywXG5O08dm7oT+QD81eX8oalQdjBYDxrduuQhyTlrqm+fLg X-Received: by 2002:a17:906:1748:b0:7b2:7fa8:3d84 with SMTP id d8-20020a170906174800b007b27fa83d84mr13071493eje.650.1668990292446; Sun, 20 Nov 2022 16:24:52 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j19-20020a170906831300b007ae9fc42919si6560668ejx.907.2022.11.20.16.24.51; Sun, 20 Nov 2022 16:24:52 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=N8fNTmpS; 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 5CC8368B53C; Mon, 21 Nov 2022 02:24:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075065.outbound.protection.outlook.com [40.92.75.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B89E68B53C for ; Mon, 21 Nov 2022 02:24:42 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ll+T8VZsf3FRhjafnl+lEEd+HXlNsHuVlK4A3P2ARKBUyKBEl+ApEYdIJP4/kEBnw3vStLA1E6zgsaPcAC6JsTE+jMFUDjV82VxyJjq5grWckJFQdTfiZC04VdKsG4ujY28TGBAgMPEWfU9I8SDnrctLEV82asck6HlOYw277SuKmxIK6O5IQyH7w/sXzIoKle9iuDKzcZcjhMRIu1pBqogvE4IFfkwS9JxErrCHlTeMeT6L8m6aYtFAXIS6SKditLfKSXBDd+iO9F4n/jsv+YYcq+JCcQKUGaKEjAplbdgcmYolYOyoHtMddxUgggFqHX6v4QbJsXerB26R7YIUJg== 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=99XPtl9yMnFi+Khp7+nAiynmsh4Km2x8rPmogJfv02U=; b=odkNc06qJkJdU/tw7Iuw/fxxTkhQNCeiLvO/O/A6R4t0dDXzAAEO+eOVr9vmQevYG6V2PCdPk19pN1HMNHNS85Ssqlrxcy7PJYQ3Kunt4ylEHybH+x/CGH0sOErlXTNcK68NLdnvj4N5I6nNtSfqDaz9lTo8kiFXzlmd94hWbP+RDMdXbGJy7iNjq4tow5irf1YTpzoGlpHRaAzWbYgEXXE07gXvM9r1h3xSQXsR1y6kNNtAPGAEhgFp+liYOfw76m85xcfoY30xvuXZ/+qM/xeQMJkt8U7wEzNqcU9yYN7e5F+Zo5ZX2HYpRl3QqMlBai+PMsEp/mPc2hfgbLsv6g== 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=99XPtl9yMnFi+Khp7+nAiynmsh4Km2x8rPmogJfv02U=; b=N8fNTmpSYNILBkECpaxXdd5VlTrEYUHtAaaSIfX+FsxkmsD0cfuQlraptEFeVO4Y6sj6k6LDvfJCcuQq2B6//nrrKpf27UKuUTlRD+/jKfOTHZM8jnhco8OdEQCn3qSFn40N81kYJ2oa+xCjxItErU0t6O68zE8m35b90mgSn09zgX6DhDghkX84vuUBiatG/joBQ+ZwUEjcvfWCFZ3++M1Hrb49nrX1dSu26NXCEwHDrCQaLv1sTY1of3CcY5qqrV1iazIIeamcqOmB781rGmNL2xOgSByk6ZiA/cJjUuR0202Ty5lJePRFd0B/TQ8AxX+qayt4MRpJNHtJEThJZA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AM8P250MB0198.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:325::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.9; Mon, 21 Nov 2022 00:24:41 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::c37:cabe:316a:60b2]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::c37:cabe:316a:60b2%4]) with mapi id 15.20.5834.011; Mon, 21 Nov 2022 00:24:41 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Nov 2022 01:24:46 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [NsnSFdwFUSLEQZsv7lXt1i+MnF+VuPO5+pzsEhlS4pY=] X-ClientProxiedBy: FR0P281CA0102.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::18) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20221121002451.2127852-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AM8P250MB0198:EE_ X-MS-Office365-Filtering-Correlation-Id: f8ef50bd-fd3a-4459-a1fd-08dacb56c6ea X-MS-Exchange-SLBlob-MailProps: AZnQBsB9Xmo0aNP8rr9jcnEY1WaRr0IFEQ67+qYO8Gf4KeggOEjo2sLtOUjBpbOVPP0QoxKLHLdcf34rKr0iRw8wqCFWPi52kLwtILiEHYzk5alfSmTmT/EJkhpjlbIUYFV2MVjiamWOCSKJRoafeyREhvJNIYWattTp9E5yCbiEvZp+Mqvetb2Z7cm0gVZEzwyu4DjgpAYaIEEQH8gL5XHfkW/S0jVhvqHtiE4fHSMNNpHEwsuVucYRikmEW6sCIDW9cYMUTkgu1lr+fRrpeVdkEo6eA0SRdujhKAJk3dsFRr9W048zepvpmYMmKoVImp5n0IVIfjcQoBIac0wpifUHZ9eaMLs0P1v+X1fxlnKWmRA3OSZaGwLHUdrZ2FSKJRi2N80YTDlEfOAebA57F5H+j+AKwNX4Kx/PLgEuGDL6KDfcHc/0s0ojlksLx+XiERlveUyXWlO/ILsbfhpziSIeNdApw4DVZm0EC33YrMqmPmDEdEnKfKwdWkoaFns2buA+ZTeOgMoo4Gp/eUdviyTj1/JEspr0ycW9tc4aVuyxhJyphXxFechGXiMvNUjveH74+XyaCx5H3q4kIeDJFlYy1J+NYRpz1Gf/PMjhgTJMfcYQvfxYWzxGtbBRsKv+31EnCpOpj7MT5oxJI526o72u4LNVZHPnrKBxNuI3gbeprfIVivQMtK1ElyfD6fGMWPJpoRtqlsld05uWErUW8zpwmUuZwbh+Wt3HE3TGDBFWpHh4XHwPPKYEZfySQtt5bT8OCqUvg4I= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vQYrmht6ADoYe5E66Aql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MY656rtpx53sTOTbpxTcGP+j3w74bu44FwenPDJObu7e+kh6GD4yX7+2clyvVAKNrgAY/dH3fEuYCkKv0tsTEzwrW3VFIKi2H7XEgKzATKL7X3JCeNmPQxIwB+K5HplnTlIeOL+dwllG0bxpQs+iL3NuUoe2HgFETyAkwWv6I14L9s+RzKLnvrlVOchmYp7LpLeqVDCxLhadWsTNCv0Cg3HfgUqyzCS8WoxsSx0m4xZwwKTb5o/mx/6rO6ygFJMoLroG+0E2ny78IYYhZ9KoUMPsZgiZozr11RWBgM79ODIHwlE5RGHJMeIC1oacoGktAahURNjzkvV0gZPuvF6TI5lfQUELvwMUb8vdImkrxhbvPYG5zokp56LY7KXEl/W4jbTJmMMcmjjFa8CsYZoP1i0OV1jvbOlWvCeEeO9s64TwU/P6tY8xk5eCleqsOkVixCsc4K5NEN51kVEurE7OlDAc+ETBwfailyt5z3o9vPsY+vJP+0blrlPydm4dFZoiOfx4uC7v4orzhTx8RN1o9ltj1nmS4q2eXDdlUvjVTs+S3unCaEGN1uy+FX96Mcbad71hpKtrJbRykvOiHx3Z7r9zUhYAEcqU3X4DTSz3ufMJKaFFvbeR1MZX5oXLoRbL7xeKJSW3HBoD8emk2z9eNaxsRYxuRd1ppA5zon6YrZA9OYpM4uOzIO0Z50ZDfhTiHeWtZDbmwjz4C5DFr8EasYHRIq/VwjPTUmIrPWxl1PKasBf5J+TsnmhULpaH1tqJJyVs3y6r59qpfrXARZDJyE23mzAXr5SEXxRGRFvYNobUTW2HJFq4hKKWJfquHJbmwa2TWk8btD2w2M4x64RLZGH5W3pn/sk5FbcrfMIDiAzoIqq11lFAlbmvfAL6FAhiIWddPRZ9IBn2iqxQt8+RUptbMpo/M3niexlykdt52ZE4mR0JL74AxVhaSr/j+KnkWlvZjlUMeuyoHr6YuJtS X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8ef50bd-fd3a-4459-a1fd-08dacb56c6ea X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2022 00:24:41.0000 (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: AM8P250MB0198 Subject: [FFmpeg-devel] [PATCH 1/6] swscale/utils: Factor initializing single slice context out 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: JR1leoarV5vN Initializing slice threads currently uses the function (sws_init_context()) that is also used for initializing user-facing contexts with the only difference being that nb_threads is set to one before initializing the slice contexts. Yet sws_init_context() also initializes lots of stuff that is not slice-dependent, i.e. (src|dst)Range. This currently only works because the code sets these fields to the same values for all slice contexts. This is not nice; even worse, it entails that log messages are printed once per slice context (and therefore fill the screen). This commit lays the groundwork to fix this. Signed-off-by: Andreas Rheinhardt --- libswscale/utils.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 85640a143f..c6fa07f752 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1268,6 +1268,9 @@ static enum AVPixelFormat alphaless_fmt(enum AVPixelFormat fmt) } } +static int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter, + SwsFilter *dstFilter); + static int context_init_threaded(SwsContext *c, SwsFilter *src_filter, SwsFilter *dst_filter) { @@ -1301,7 +1304,7 @@ static int context_init_threaded(SwsContext *c, c->slice_ctx[i]->nb_threads = 1; - ret = sws_init_context(c->slice_ctx[i], src_filter, dst_filter); + ret = sws_init_single_context(c->slice_ctx[i], src_filter, dst_filter); if (ret < 0) return ret; @@ -1322,8 +1325,8 @@ static int context_init_threaded(SwsContext *c, return 0; } -av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, - SwsFilter *dstFilter) +static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter, + SwsFilter *dstFilter) { int i; int usesVFilter, usesHFilter; @@ -1344,13 +1347,6 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, static const float float_mult = 1.0f / 255.0f; static AVOnce rgb2rgb_once = AV_ONCE_INIT; - if (c->nb_threads != 1) { - ret = context_init_threaded(c, srcFilter, dstFilter); - if (ret < 0 || c->nb_threads > 1) - return ret; - // threading disabled in this build, init as single-threaded - } - cpu_flags = av_get_cpu_flags(); flags = c->flags; emms_c(); @@ -2054,6 +2050,21 @@ fail: // FIXME replace things by appropriate error codes return ret; } +av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, + SwsFilter *dstFilter) +{ + int ret; + + if (c->nb_threads != 1) { + ret = context_init_threaded(c, srcFilter, dstFilter); + if (ret < 0 || c->nb_threads > 1) + return ret; + // threading disabled in this build, init as single-threaded + } + + return sws_init_single_context(c, srcFilter, dstFilter); +} + SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, const double *param)