From patchwork Tue Sep 28 05:34:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30616 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp4860054iob; Mon, 27 Sep 2021 22:34:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAWuhCNehCbT9H9tkFrftMmdpUWU+kHslQT4Fzp3HBuU5yJ+cW/XsIA6aIE1iwKe+cHovY X-Received: by 2002:a17:906:b00a:: with SMTP id v10mr4788333ejy.158.1632807271410; Mon, 27 Sep 2021 22:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632807271; cv=none; d=google.com; s=arc-20160816; b=Q5xq306NbxCr4se5iZ3pIXnV+xtGmfuc1yu00Shz7QLwMTxTTw4cN0sDi+3K5T19QW qIBGXPLPxXVu24ypAcw/iAV4a91qrZA+so/o9PCG76e4N7PIXhmv8VZV7/Yl6uCcfSYc AHgXBSR7ExnvvVXRVwb+08XW4ERNj67Jq8U/MbAeU3eYtlLcVYxzz4lWRSc4DPI+83yl kOQdjpVFVSo+7b19lxrTNUPjYjdtmMYbkGXR8dJ2XaP/nXLD0D+38s2DQXb9PuCvfeuJ FGDcjzI2qhbsXTaOiQFbjU1f8G3a33LHoGuKDKlObl0CsRGg7oFOvlkGU8bQQE1ktHe9 4zbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to; bh=NKlJyhtc6JbT8SGZXIdRI4jd0GtqQgXmew3MPddO+YE=; b=RbghWA3XFc1FKdA2jkDyvr0fPlncLN0tvfFgsZxauASKUfFfFu564ML8ZGGgLI7sdp /rgv4HLVyRNak/YQiI1y9DLcahCB9KojNVNFQhq6MWzFUd2QQEjxRQmXc8EdrpruUdvg NT73AcS9bNnkrtXkfoUes8SuYJ4wKSWn4dQxHCT3yx885BEZ5Fj5QRxTcMG+BrNfFXS3 K5iJIkP14Y/2Qd2eFMw8aEhPQs420UPOMHJwpNbaUQn9whHAd4GzWkJb3brR15WpkpAE 1dke9yUxkBtkS7dF/ouyoe1sv/jVjH6+iLaOcYTHEKcPBYfa/jFLrLGai705fj9kdEhr towA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 1si10397546ejn.101.2021.09.27.22.34.30; Mon, 27 Sep 2021 22:34:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 675CC687F21; Tue, 28 Sep 2021 08:34:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 65984688113 for ; Tue, 28 Sep 2021 08:34:18 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10120"; a="224689068" X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="224689068" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 22:34:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="553794973" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2021 22:34:14 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Sep 2021 13:34:01 +0800 Message-Id: <20210928053404.30714-1-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/4] libswscale/x86/rgb2rgb: add shuffle_bytes avx2 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: X20jfJygTSz/ Performance data(Less is better): shuffle_bytes_ssse3 3.64654 shuffle_bytes_avx2 0.94288 Signed-off-by: Wu Jianhua --- libswscale/x86/rgb2rgb.c | 17 +++++++++++++++-- libswscale/x86/rgb_2_rgb.asm | 11 +++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c index c38a953277..0ab139aca4 100644 --- a/libswscale/x86/rgb2rgb.c +++ b/libswscale/x86/rgb2rgb.c @@ -146,6 +146,12 @@ void ff_shuffle_bytes_3012_ssse3(const uint8_t *src, uint8_t *dst, int src_size) void ff_shuffle_bytes_3210_ssse3(const uint8_t *src, uint8_t *dst, int src_size); #if ARCH_X86_64 +void ff_shuffle_bytes_2103_avx2(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_0321_avx2(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_1230_avx2(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_3012_avx2(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_3210_avx2(const uint8_t *src, uint8_t *dst, int src_size); + void ff_uyvytoyuv422_sse2(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride); @@ -186,9 +192,16 @@ av_cold void rgb2rgb_init_x86(void) shuffle_bytes_3012 = ff_shuffle_bytes_3012_ssse3; shuffle_bytes_3210 = ff_shuffle_bytes_3210_ssse3; } - if (EXTERNAL_AVX(cpu_flags)) { #if ARCH_X86_64 + if (EXTERNAL_AVX2_FAST(cpu_flags)) { + shuffle_bytes_0321 = ff_shuffle_bytes_0321_avx2; + shuffle_bytes_2103 = ff_shuffle_bytes_2103_avx2; + shuffle_bytes_1230 = ff_shuffle_bytes_1230_avx2; + shuffle_bytes_3012 = ff_shuffle_bytes_3012_avx2; + shuffle_bytes_3210 = ff_shuffle_bytes_3210_avx2; + } + if (EXTERNAL_AVX(cpu_flags)) { uyvytoyuv422 = ff_uyvytoyuv422_avx; -#endif } +#endif } diff --git a/libswscale/x86/rgb_2_rgb.asm b/libswscale/x86/rgb_2_rgb.asm index 29b856e281..c695c61d5c 100644 --- a/libswscale/x86/rgb_2_rgb.asm +++ b/libswscale/x86/rgb_2_rgb.asm @@ -159,6 +159,17 @@ SHUFFLE_BYTES 1, 2, 3, 0 SHUFFLE_BYTES 3, 0, 1, 2 SHUFFLE_BYTES 3, 2, 1, 0 +%if ARCH_X86_64 +%if HAVE_AVX2_EXTERNAL +INIT_YMM avx2 +SHUFFLE_BYTES 2, 1, 0, 3 +SHUFFLE_BYTES 0, 3, 2, 1 +SHUFFLE_BYTES 1, 2, 3, 0 +SHUFFLE_BYTES 3, 0, 1, 2 +SHUFFLE_BYTES 3, 2, 1, 0 +%endif +%endif + ;----------------------------------------------------------------------------------------------- ; uyvytoyuv422(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, ; const uint8_t *src, int width, int height, From patchwork Tue Sep 28 05:34:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30615 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp4860181iob; Mon, 27 Sep 2021 22:34:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFJ/maIF98+tRQ8UVkyPFlmtJGFxQFB542kMrNLlmNVGjreGxNXiV2YrWmbtkIrJlufK7L X-Received: by 2002:a05:6402:220c:: with SMTP id cq12mr3479620edb.229.1632807281993; Mon, 27 Sep 2021 22:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632807281; cv=none; d=google.com; s=arc-20160816; b=Rr8MZ3VaxlkDIbIwCBKkCQfAwb7PtPKtPd+1FAjBeEG+dYiwfQKlvP1DCjg/CkoL/E b3lrrBLiB0Geudvtklc37qmrtzUXH5HrUlKoemI+l48Pl+jZF2xGADUgMi/5b8qj5hvz Xe7j3Yk+Pjpc3nLyvSChzCh6As55QRl7sKJv4QFemKuANnST01MfwUfS35SC6LCx0fIu pCHpNztDH4qo4RMBb2suDpZEu8Qn8LLlNrCQG2KD/6bGg71cofK6/Y5P0yx1LxQQa6cf 0eaXiJYnFmF2aoYSLX+rDaadCN0ZbWrVprwi5yGuSlcBCJmZr7t2R+g6lQZJf4cBRgvP XvNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=5LmGoIWB6ei3fRVhDYbfbPC4NjUkhm9ck+ioXBPsvrE=; b=ScGaebMz+CJAwJoFs97l+He1of24fRzWXqrFvXgzyeh6JkmnNwJGj+U2SwoVVdqQds GOg6z5WoESSVunIE5csE4BykS9xqthfcX9s4uH7/DZN6qx0yoTGqHzYLufSwWaOayUeP 3oNmysRBe6zF+jJa9eptyR/ubZ0J9OvJ8xKs3oamMpSPa0ibwPynUnBjfhWGl3fBMOxe wvy0rDc8rWWjV012xHQV6w+KS9NCYZ/iQMnldgkmIsej10zUsr5rVR17NyOZtjuyIqfx TaNiBkV8cSYCsLx8l+6zsQFhwPn3cZjxbWHC5LIJZedREg1dqOdtOuaVxW4/QKkcMH6k lsFQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g21si14225718edb.488.2021.09.27.22.34.41; Mon, 27 Sep 2021 22:34:41 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 78D2B68A24C; Tue, 28 Sep 2021 08:34:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7E0D868076B for ; Tue, 28 Sep 2021 08:34:20 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10120"; a="224689069" X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="224689069" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 22:34:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="553794981" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2021 22:34:15 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Sep 2021 13:34:02 +0800 Message-Id: <20210928053404.30714-2-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210928053404.30714-1-jianhua.wu@intel.com> References: <20210928053404.30714-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 2/4] libswscale/x86/rgb2rgb: add shuffle_bytes avx512 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: hEaTndNWDfgU Performance data(Less is better): shuffle_bytes_avx2 0.94288 shuffle_bytes_avx512 0.60049 Signed-off-by: Wu Jianhua --- libswscale/x86/rgb2rgb.c | 13 +++++++++++++ libswscale/x86/rgb_2_rgb.asm | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c index 0ab139aca4..c9ff33ab77 100644 --- a/libswscale/x86/rgb2rgb.c +++ b/libswscale/x86/rgb2rgb.c @@ -152,6 +152,12 @@ void ff_shuffle_bytes_1230_avx2(const uint8_t *src, uint8_t *dst, int src_size); void ff_shuffle_bytes_3012_avx2(const uint8_t *src, uint8_t *dst, int src_size); void ff_shuffle_bytes_3210_avx2(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_2103_avx512(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_0321_avx512(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_1230_avx512(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_3012_avx512(const uint8_t *src, uint8_t *dst, int src_size); +void ff_shuffle_bytes_3210_avx512(const uint8_t *src, uint8_t *dst, int src_size); + void ff_uyvytoyuv422_sse2(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride); @@ -200,6 +206,13 @@ av_cold void rgb2rgb_init_x86(void) shuffle_bytes_3012 = ff_shuffle_bytes_3012_avx2; shuffle_bytes_3210 = ff_shuffle_bytes_3210_avx2; } + if (EXTERNAL_AVX512(cpu_flags)) { + shuffle_bytes_0321 = ff_shuffle_bytes_0321_avx512; + shuffle_bytes_2103 = ff_shuffle_bytes_2103_avx512; + shuffle_bytes_1230 = ff_shuffle_bytes_1230_avx512; + shuffle_bytes_3012 = ff_shuffle_bytes_3012_avx512; + shuffle_bytes_3210 = ff_shuffle_bytes_3210_avx512; + } if (EXTERNAL_AVX(cpu_flags)) { uyvytoyuv422 = ff_uyvytoyuv422_avx; } diff --git a/libswscale/x86/rgb_2_rgb.asm b/libswscale/x86/rgb_2_rgb.asm index c695c61d5c..3380a1272c 100644 --- a/libswscale/x86/rgb_2_rgb.asm +++ b/libswscale/x86/rgb_2_rgb.asm @@ -168,6 +168,14 @@ SHUFFLE_BYTES 1, 2, 3, 0 SHUFFLE_BYTES 3, 0, 1, 2 SHUFFLE_BYTES 3, 2, 1, 0 %endif +%if HAVE_AVX512_EXTERNAL +INIT_ZMM avx512 +SHUFFLE_BYTES 2, 1, 0, 3 +SHUFFLE_BYTES 0, 3, 2, 1 +SHUFFLE_BYTES 1, 2, 3, 0 +SHUFFLE_BYTES 3, 0, 1, 2 +SHUFFLE_BYTES 3, 2, 1, 0 +%endif %endif ;----------------------------------------------------------------------------------------------- From patchwork Tue Sep 28 05:34:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30617 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp4860264iob; Mon, 27 Sep 2021 22:34:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkDEw3rpS50OB9N7Aj/bOHKwBHy76pWz32PUESCdM9XH4b3zeiwR/xp5tahMNZ6fjFpapo X-Received: by 2002:a50:e0c9:: with SMTP id j9mr5280439edl.336.1632807291640; Mon, 27 Sep 2021 22:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632807291; cv=none; d=google.com; s=arc-20160816; b=BsjhBq2RST9ETmKY1QNCRzxLLTFrFGo4FR3WDh6rpkn+MjN4VlPm3A0N1JcQah64HA nENLZpFs761tmoOQ64zkbpw+nYyonFoV26/WAwFfw7baOqM3q0SWByHxGP090DHp65oF gOUB/DW43sexpnXXfEN6mScHhuF2wQoFkwISMTxPteRK8jYSi5DG6Ym1xBxcinwrXWkr UEmSx2DWY/VHan5rXdNjECCVuJn9ehPWTlOX21pNBugwo8WmXkTDphymfQ8fbpHw/k5G 6YKrobkeZWNGuUJKeMjj0MgQZZ3tvwXibR5pQ5LrzCawuVRpRsw4+65ua1+r71JTSRxa CHyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=gNZOWaElnBSBIgsJHm2iGYgToqzorQK8o1wahvlQmUc=; b=LmsjGq6EfwF2jYiPalajve281BABbzwN63qcXBXm9cGmAk5nwVRxNzFnioFbmYq55M LbgzM5ZsF3L8pGghJiscGXZ0AbXkpH3ximPWTGiLRQj3VVQLMQbdRQPl951XrJo826qh uKe0UG4Aa1Dnr8b37ZpiU38dzohjoM9jnSqtfS0wnTSBgluaRsfDghLLbqWQAQ6/W1wZ AAGnlZIhGra9elPIODoVbYEXqe6D94WS4vuQOWNhb95VmDQQ0WvSOI3uqb7XSEcnfhTf zepkV4nH/04LcXWl3y0h05YUpCTbhxD6970kSllmP0pKESqSfmeqM//zx2qEysU9g9Vo sdHQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ch26si16225557edb.220.2021.09.27.22.34.51; Mon, 27 Sep 2021 22:34:51 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 862FF68A32E; Tue, 28 Sep 2021 08:34:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2460D68076B for ; Tue, 28 Sep 2021 08:34:24 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10120"; a="224689073" X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="224689073" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 22:34:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="553794989" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2021 22:34:16 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Sep 2021 13:34:03 +0800 Message-Id: <20210928053404.30714-3-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210928053404.30714-1-jianhua.wu@intel.com> References: <20210928053404.30714-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 3/4] libswscale/x86/rgb2rgb: add uyvytoyuv422 avx2 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YvNppzdAOsLv With the accelerating by means of AVX2, the uyvytoyuv422 can be faster Performance data(Less is better): uyvytoyuv422_sse2 0.49381 uyvytoyuv422_avx 0.42981 uyvytoyuv422_avx2 0.27915 Signed-off-by: Wu Jianhua --- libswscale/x86/rgb2rgb.c | 6 +++++ libswscale/x86/rgb_2_rgb.asm | 48 +++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c index c9ff33ab77..a965a1755c 100644 --- a/libswscale/x86/rgb2rgb.c +++ b/libswscale/x86/rgb2rgb.c @@ -164,6 +164,9 @@ void ff_uyvytoyuv422_sse2(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, void ff_uyvytoyuv422_avx(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride); +void ff_uyvytoyuv422_avx2(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, + const uint8_t *src, int width, int height, + int lumStride, int chromStride, int srcStride); #endif av_cold void rgb2rgb_init_x86(void) @@ -216,5 +219,8 @@ av_cold void rgb2rgb_init_x86(void) if (EXTERNAL_AVX(cpu_flags)) { uyvytoyuv422 = ff_uyvytoyuv422_avx; } + if (EXTERNAL_AVX2_FAST(cpu_flags)) { + uyvytoyuv422 = ff_uyvytoyuv422_avx2; + } #endif } diff --git a/libswscale/x86/rgb_2_rgb.asm b/libswscale/x86/rgb_2_rgb.asm index 3380a1272c..683bd067a5 100644 --- a/libswscale/x86/rgb_2_rgb.asm +++ b/libswscale/x86/rgb_2_rgb.asm @@ -31,9 +31,16 @@ pb_shuffle0321: db 0, 3, 2, 1, 4, 7, 6, 5, 8, 11, 10, 9, 12, 15, 14, 13 pb_shuffle1230: db 1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12 pb_shuffle3012: db 3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14 pb_shuffle3210: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 +pd_permd256_uv: dd 0, 4, 1, 5, 2, 6, 3, 7 SECTION .text +%macro VPERM 5 +%if mmsize == %2 + vperm%1 %3, %4, %5 +%endif +%endmacro + %macro RSHIFT_COPY 3 ; %1 dst ; %2 src ; %3 shift %if cpuflag(avx) @@ -198,11 +205,15 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s mov whalfq, wq shr whalfq, 1 ; whalf = width / 2 - lea srcq, [srcq + wq * 2] + lea srcq, [srcq + wq * 2] add ydstq, wq add udstq, whalfq add vdstq, whalfq +%if mmsize == 32 + movu m15, [pd_permd256_uv] +%endif + .loop_line: mov xq, wq mov wtwoq, wq @@ -251,8 +262,10 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s RSHIFT_COPY m7, m3, 1 ; UYVY UYVY -> YVYU YVY... pand m7, m1 ; YxYx YxYx... - packuswb m6, m7 ; YYYY YYYY... + + VPERM q, 32, m6, m6, 0xd8 + movu [ydstq + wq], m6 ; extract y part 2 @@ -261,8 +274,10 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s RSHIFT_COPY m7, m5, 1 ; UYVY UYVY -> YVYU YVY... pand m7, m1 ; YxYx YxYx... + packuswb m6, m7 ; YYYY YYYY... + + VPERM q, 32, m6, m6, 0xd8 - packuswb m6, m7 ; YYYY YYYY... movu [ydstq + wq + mmsize], m6 ; extract uv @@ -275,17 +290,21 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s packuswb m4, m5 ; UVUV... ; U - pand m6, m2, m1 ; UxUx... - pand m7, m4, m1 ; UxUx... + pand m6, m2, m1 ; UxUx... + pand m7, m4, m1 ; UxUx... + packuswb m6, m7 ; UUUU - packuswb m6, m7 ; UUUU - movu [udstq + whalfq], m6 + VPERM d, 32, m6, m15, m6 + movu [udstq + whalfq], m6 ; V - psrlw m2, 8 ; VxVx... - psrlw m4, 8 ; VxVx... - packuswb m2, m4 ; VVVV + psrlw m2, 8 ; VxVx... + psrlw m4, 8 ; VxVx... + packuswb m2, m4 ; VVVV + + VPERM d, 32, m2, m15, m2 + movu [vdstq + whalfq], m2 add whalfq, mmsize @@ -294,13 +313,13 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s jl .loop_simd .end_line: - add srcq, src_strideq + add srcq, src_strideq add ydstq, lum_strideq add udstq, chrom_strideq add vdstq, chrom_strideq ;restore initial state of line variable - mov wq, back_wq + mov wq, back_wq mov xq, wq mov whalfq, wq shr whalfq, 1 ; whalf = width / 2 @@ -316,4 +335,9 @@ UYVY_TO_YUV422 INIT_XMM avx UYVY_TO_YUV422 + +%if HAVE_AVX2_EXTERNAL +INIT_YMM avx2 +UYVY_TO_YUV422 +%endif %endif From patchwork Tue Sep 28 05:34:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30618 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp4860368iob; Mon, 27 Sep 2021 22:35:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8lH6/5661/PF6pKYILCKkdFDk0qnDCLROUsyvlOSYUMvvR58B9Uo5v87ZGmAb/QMlLabb X-Received: by 2002:a05:6402:21e1:: with SMTP id ce1mr5611381edb.17.1632807301760; Mon, 27 Sep 2021 22:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632807301; cv=none; d=google.com; s=arc-20160816; b=O05qQB0uJDleFgEoqlhhcFPdDmWdI/jYT80g7ZSGsBcoiJt/VHkOBMkll+lwxwZqKa 0tpX9Zh/0cSYUB7n19haSIKCBeGZcc/4i9ICzxjE7gceE0n32B4/5wVPCsRbfiQwMBkA 9eD38hwt1WpnEEqh028WfreBDfoW6hE50dlBFD/W79r5WajGvbRR9CVYCjmHZA7BWnYD MCKRBw/kZq4godSAqD5EgV3XqEWZf3hwrUnx+oUQiYOnODEZTUo9vMkbKMnQuscf5XIL zMIRMog7p95LCxdPf2K6SY+D8q1O+3wFIXWC2G4aPsaXbJHN80iNgfezvPYaBEagTobQ 92/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=ME1UhDB+J5C0jn0hEjNjFbloCDewJuWvGzFSHXByIVI=; b=HgRQmAcHs3o376TE3MqgABB2PXPzDFcwXl6CYGrICvn/tB3jE9mdnyVArkNJSZ2pLt UP5oZ+R8sb6u2nsz8972r3wcd1h3JkWfYq6XmdN0GCZOquJZXdYaXir0800s85zUAa3G ZZ+OY+ZtusQQQfDLWGSfV3n/gDJVTCDHIVFdcLbRzZyyJlAskj5MdBqLIDKSCzlDDFkC aQ5EMbPu+b7cqjB4wlTIB/JhigAvtG49/UQboj0KzuThxwd1Hc8oNlv8kc70qjd8GvHw bUVMKjXGEvtXr9QFroZCzPMqvioTARKCXhr+7VigvkAPhjey+EgrBvPfFp0o0yPgqSM1 R8VA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 14si18267720ejf.337.2021.09.27.22.35.01; Mon, 27 Sep 2021 22:35:01 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2513268A3A8; Tue, 28 Sep 2021 08:34:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78B4C68A329 for ; Tue, 28 Sep 2021 08:34:26 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10120"; a="224689074" X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="224689074" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 22:34:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="553794995" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2021 22:34:17 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Sep 2021 13:34:04 +0800 Message-Id: <20210928053404.30714-4-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210928053404.30714-1-jianhua.wu@intel.com> References: <20210928053404.30714-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 4/4] libswscale/x86/rgb2rgb: add uyvytoyuv422 avx512 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VwTgr8QAPwmg With the accelerating by means of AVX512, the uyvytoyuv422 can be faster. Performance data(Less is better): uyvytoyuv422_avx2 0.27915 uyvytoyuv422_avx512 0.16442 Signed-off-by: Wu Jianhua --- libswscale/x86/rgb2rgb.c | 6 ++++++ libswscale/x86/rgb_2_rgb.asm | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c index a965a1755c..c59136a352 100644 --- a/libswscale/x86/rgb2rgb.c +++ b/libswscale/x86/rgb2rgb.c @@ -167,6 +167,9 @@ void ff_uyvytoyuv422_avx(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, void ff_uyvytoyuv422_avx2(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride); +void ff_uyvytoyuv422_avx512(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, + const uint8_t *src, int width, int height, + int lumStride, int chromStride, int srcStride); #endif av_cold void rgb2rgb_init_x86(void) @@ -222,5 +225,8 @@ av_cold void rgb2rgb_init_x86(void) if (EXTERNAL_AVX2_FAST(cpu_flags)) { uyvytoyuv422 = ff_uyvytoyuv422_avx2; } + if (EXTERNAL_AVX512(cpu_flags)) { + uyvytoyuv422 = ff_uyvytoyuv422_avx512; + } #endif } diff --git a/libswscale/x86/rgb_2_rgb.asm b/libswscale/x86/rgb_2_rgb.asm index 683bd067a5..552967b6a2 100644 --- a/libswscale/x86/rgb_2_rgb.asm +++ b/libswscale/x86/rgb_2_rgb.asm @@ -31,7 +31,9 @@ pb_shuffle0321: db 0, 3, 2, 1, 4, 7, 6, 5, 8, 11, 10, 9, 12, 15, 14, 13 pb_shuffle1230: db 1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12 pb_shuffle3012: db 3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14 pb_shuffle3210: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 +pd_permd512_uv: dd 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15 pd_permd256_uv: dd 0, 4, 1, 5, 2, 6, 3, 7 +pq_permq512_yy: dq 0, 2, 4, 6, 1, 3, 5, 7 SECTION .text @@ -193,7 +195,11 @@ SHUFFLE_BYTES 3, 2, 1, 0 %macro UYVY_TO_YUV422 0 cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_stride, src_stride, wtwo, whalf, tmp, x, back_w pxor m0, m0 +%if mmsize == 64 + vpternlogd m1, m1, m1, 0xff +%else pcmpeqw m1, m1 +%endif psrlw m1, 8 movsxdifnidn wq, wd @@ -212,6 +218,9 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s %if mmsize == 32 movu m15, [pd_permd256_uv] +%elif mmsize == 64 + movu m14, [pq_permq512_yy] + movu m15, [pd_permd512_uv] %endif .loop_line: @@ -265,6 +274,7 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s packuswb m6, m7 ; YYYY YYYY... VPERM q, 32, m6, m6, 0xd8 + VPERM q, 64, m6, m14, m6 movu [ydstq + wq], m6 @@ -277,6 +287,7 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s packuswb m6, m7 ; YYYY YYYY... VPERM q, 32, m6, m6, 0xd8 + VPERM q, 64, m6, m14, m6 movu [ydstq + wq + mmsize], m6 @@ -295,6 +306,7 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s packuswb m6, m7 ; UUUU VPERM d, 32, m6, m15, m6 + VPERM d, 64, m6, m15, m6 movu [udstq + whalfq], m6 @@ -304,6 +316,7 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s packuswb m2, m4 ; VVVV VPERM d, 32, m2, m15, m2 + VPERM d, 64, m2, m15, m2 movu [vdstq + whalfq], m2 @@ -340,4 +353,8 @@ UYVY_TO_YUV422 INIT_YMM avx2 UYVY_TO_YUV422 %endif +%if HAVE_AVX512_EXTERNAL +INIT_ZMM avx512 +UYVY_TO_YUV422 +%endif %endif