From patchwork Mon May 31 07:55:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28001 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657640iof; Mon, 31 May 2021 00:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5FjvmHgplXzf4oCeJ7Bcxzeae1Kibv23kkR7nGkOrMeVj61+lFSjM47Z/2HTm+1RB4XCd X-Received: by 2002:a17:906:13cb:: with SMTP id g11mr3788433ejc.169.1622447930015; Mon, 31 May 2021 00:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447930; cv=none; d=google.com; s=arc-20160816; b=vKFoKbkOvuf2lbpfmkrjvvsglSWvUe6tFEp/wny9JrjUazvaTfqNHlonDKBRjNVXQj XsevEx8rZe+H8jjsYq3svF6UY7E2tDItCisCz9qgX7ntLNa3l14vbWsxvIlWkHG8eyUA I3I0UrVbN1KlVF2gnC8SqPFs7vgTUjvtGF85q6FtRcF1msYBySyu1x7h0jRZ+ms9/J9t vcPoPMrpb+ZiDwDJCv0A6T11SJV+ARgPuoG6ixp75uaFNFnYss2V7vAA96Gh4ayRCnkV IXjryh8/9NrDgz7cg4bAs5zbPFN8rcwBvmKxtmWh5Iy4Qof5m6YXA1Ja3RjCMsFMB6kd wHOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=Z2Qkzgsyuv86LIF0rvmUA6eDDWiiieB5uMYIUXK4Z3A=; b=XYakaLsIXWLxPDX8fkO5OyrCTd454ebODLWzuifBdHN1/u5R7ppmCD4gUZs+WqDHt5 hQ+VcbKasDQzJv3RxhsWX0MXK/uw44PppldkCaIRxilln4b+kPryLZpEZtF+B//0x6pI SVlecNPbOLOjszv2wzyllyffYyv1gRNxSelkaiYFKKhTnUUeQhPNd7itaZ7i2rJQfBF6 u0ohBxEMWYsqeL9XPa4SN6gSY5wrgkQd/5GIPd4Mt3TFWjWSPmfZwPIoze7pgZo72Yx0 YQZ13bnv99FKVqQdg8j5QoG2n17Ulyma6BREsqohjpKyDrYPo8x08VDLd9Of4Knxhbpo aq7g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m1si14319858ejj.42.2021.05.31.00.58.49; Mon, 31 May 2021 00:58:50 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A6FFE689AEE; Mon, 31 May 2021 10:55:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2166E68838E for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D4049240697 for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id AanHuG7WjbmQ for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id EBF93240698 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 098723A1601; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:03 +0200 Message-Id: <20210531075515.19544-12-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/24] sws: separate the calls to scaled vs unscaled conversion 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: T5kzpRmoouTo Call the scaler function directly rather than through a function pointer. Drop the now-unused return value from ff_getSwsFunc() and rename the function to reflect its new role. This will be useful in the following commits, where it will become important that the amount of output is different for scaled vs unscaled case. --- libswscale/swscale.c | 10 ++++++---- libswscale/swscale_internal.h | 6 +----- libswscale/utils.c | 3 ++- tests/checkasm/sw_scale.c | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2db40a6807..4b577ef263 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -579,7 +579,7 @@ static av_cold void sws_init_swscale(SwsContext *c) c->needs_hcscale = 1; } -SwsFunc ff_getSwsFunc(SwsContext *c) +void ff_sws_init_scale(SwsContext *c) { sws_init_swscale(c); @@ -591,8 +591,6 @@ SwsFunc ff_getSwsFunc(SwsContext *c) ff_sws_init_swscale_aarch64(c); if (ARCH_ARM) ff_sws_init_swscale_arm(c); - - return swscale; } static void reset_ptr(const uint8_t *src[], enum AVPixelFormat format) @@ -988,7 +986,11 @@ int attribute_align_arg sws_scale(struct SwsContext *c, /* reset slice direction at end of frame */ if (srcSliceY_internal + srcSliceH == c->srcH) c->sliceDir = 0; - ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); + + if (c->swscale) + ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); + else + ret = swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); if (c->dstXYZ && !(c->srcXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) { int dstY = c->dstY ? c->dstY : srcSliceY + srcSliceH; diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index e8a434427b..02a45e7adb 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -872,11 +872,7 @@ void ff_get_unscaled_swscale_ppc(SwsContext *c); void ff_get_unscaled_swscale_arm(SwsContext *c); void ff_get_unscaled_swscale_aarch64(SwsContext *c); -/** - * Return function pointer to fastest main scaler path function depending - * on architecture and available optimizations. - */ -SwsFunc ff_getSwsFunc(SwsContext *c); +void ff_sws_init_scale(SwsContext *c); void ff_sws_init_input_funcs(SwsContext *c); void ff_sws_init_output_funcs(SwsContext *c, diff --git a/libswscale/utils.c b/libswscale/utils.c index d45d7afcbf..42bef3753f 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1845,7 +1845,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, } } - c->swscale = ff_getSwsFunc(c); + ff_sws_init_scale(c); + return ff_init_filters(c); nomem: ret = AVERROR(ENOMEM); diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c index 3ac0f9082f..40c5eb3aa8 100644 --- a/tests/checkasm/sw_scale.c +++ b/tests/checkasm/sw_scale.c @@ -93,7 +93,7 @@ static void check_yuv2yuvX(void) if (sws_init_context(ctx, NULL, NULL) < 0) fail(); - ff_getSwsFunc(ctx); + ff_sws_init_scale(ctx); for(isi = 0; isi < INPUT_SIZES; ++isi){ dstW = input_sizes[isi]; for(osi = 0; osi < 64; osi += 16){ @@ -210,7 +210,7 @@ static void check_hscale(void) filter[SRC_PIXELS * width + i] = rnd(); } - ff_getSwsFunc(ctx); + ff_sws_init_scale(ctx); if (check_func(ctx->hcScale, "hscale_%d_to_%d_width%d", ctx->srcBpc, ctx->dstBpc + 1, width)) { memset(dst0, 0, SRC_PIXELS * sizeof(dst0[0]));