From patchwork Thu Sep 30 08:50:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30689 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp440971iob; Thu, 30 Sep 2021 01:51:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLCZp6HbGwZO5f0kv6BEHW16ls9JrGE7zzTEBH6IuKtjhq7kEWzKxREg5dNkc0Vdukjpxd X-Received: by 2002:a17:906:1755:: with SMTP id d21mr5314339eje.257.1632991871299; Thu, 30 Sep 2021 01:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632991871; cv=none; d=google.com; s=arc-20160816; b=Yzy20Po7HGqHj1jqNnZkKbEdeeUr7wmfJHmDJECEdDVFG2EIcQMlcqGFVLQqIOR2wo pSsUmTwJINdkx8mvD8VsxtkrckBdh47yNAoU7RJRx6i1898HAB9ub6Ho9mSR8fjZyZIv MawpI2RHbSaZK7t6FG2OrXn4TZBY52ctA9DtajZ5N7laAhR0DLOIKb8LYj5leEquvihn K37a7nca5qMk+MZ4kGhWFlIPLmk5nLPqdduEK6DE0LEUnXuxnWpGdnW0iMZbj/uktKHd SVgQADXGujyLwZMyAVWCrkSGOZkmHMu6sMr1vDr1uZ4okfpxx5K++KyvB2/hUjN1mqhu eIag== 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=g1uV9ZYyuON4vPIQvrl9bYTmY0JbqKdZfe+eticmGDPicR0s5o9UjhBnt2KMMpdw1Z aEeufEy7k+Ehf2NZTyj7uuELsmR0WY+5FFkU0tzzqb7it+jizSZOPbjUlqUVaM/QBB8e FkDwhOLayzO5ITRqkWKcfEjk8ARduWu1ADi/8eKWNUv1PzjNbCSNCicWtlcEBHvoJ5It GlIvO5fSLXNsOo/efH9smmFO+s4+okaFgIcIKXhtBAvXHJRpAA3OYAxIp3qlk4ugGuiy QmCOI2+4X8PaMiGC0seeXoYYgEsMjscrOJPDuBPKAFTr6jNImNyrNpbtxfkjsZ7sTEfv jfzA== 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 e10si3651743edj.222.2021.09.30.01.51.10; Thu, 30 Sep 2021 01:51:11 -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 C35FC68A791; Thu, 30 Sep 2021 11:51:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18D3468A306 for ; Thu, 30 Sep 2021 11:50:57 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="310684256" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="310684256" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 01:50:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="707805083" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by fmsmga006.fm.intel.com with ESMTP; 30 Sep 2021 01:50:34 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Sep 2021 16:50:20 +0800 Message-Id: <20210930085023.58812-1-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH v4 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: 1kfdya3kcMDP 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 Thu Sep 30 08:50:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30688 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp441071iob; Thu, 30 Sep 2021 01:51:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2UktO4bXJJUNqKp6K9IdvFwcCsRYp79vr2pCKnJt2xql1BAwkgbtquo5n6oBzNhBK7Esb X-Received: by 2002:a50:d802:: with SMTP id o2mr5395115edj.331.1632991883172; Thu, 30 Sep 2021 01:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632991883; cv=none; d=google.com; s=arc-20160816; b=XHUkX9NtSeqhbGDh/ju6xY7yiLh5gEB9fSNWPB0eqyXIDdOWP79DcOozAshiu6fzAQ zPdjklzE+LzRIAskpZkzhvSSwzPOcckdmWt3if3dBjNkSl8LLXy9Blw5kLixjaSkXPTQ nxjrPNI0nuicFrGnzeZPUh5WxwgUa9aJunxU0jxTGmgwLyQWuHU0Sm6Bc6Ovg/yYfSvq b94sVZcSAE6L/VQWenPsP8JRZrgAoPGtd29hU6h1SaKue7m6kPGP1pO1hmdEIlSCZ6e0 L3oPxjMUjXrRzSPM7IrLbal/zNhdwR6eeHuXSJ5Pex8ZhZMCmD3MLJ8TTgqS2XspzBKj TDAQ== 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=dlydKsLosU9NMHfNUXI7QMIVXA9IstE2ObzAoQfVNK4/7ZYtgGnPFwM96BPmXm/vDw SHXy4E9ihWFYOYgqWo51zjoI8BlJrAyO0TYkjzSBsvMrFkj6y8FEXMsiZqgccvoYFhnW MrY/QVBYS0nKUWZnBkeTL38CVPQVcf0QZ44ZQm/9BaG9oODGghY7c1JJj86FZiDf+ShM JEIZJ9g8LDaqPMF+bYLX6oaa0Ebv5nJw+e1BAG2wZAv0DKvGfWaNhs+xe/5L5LDIjCm7 nGOd4dzwmcuaNAXfkqWEKNeXY1W7xTI4RzRkJL8zTIr2J7szyJ57JxruCzamDdEjeIzY 9xFA== 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 29si2684512eje.659.2021.09.30.01.51.21; Thu, 30 Sep 2021 01:51:23 -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 D621568A7F5; Thu, 30 Sep 2021 11:51:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51C9F68A6CC for ; Thu, 30 Sep 2021 11:50:59 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="310684257" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="310684257" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 01:50:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="707805084" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by fmsmga006.fm.intel.com with ESMTP; 30 Sep 2021 01:50:35 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Sep 2021 16:50:21 +0800 Message-Id: <20210930085023.58812-2-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210930085023.58812-1-jianhua.wu@intel.com> References: <20210930085023.58812-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH v4 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: 7Nv0j7p6Ow3R 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 Thu Sep 30 08:50:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30690 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp440857iob; Thu, 30 Sep 2021 01:51:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPoTm3/2tYN0/xlvEofCVd7ZZBVhykrSBoFXuUgrWPqvF1z4oDlsDsJmAFQHyYaQ2ZTwsa X-Received: by 2002:aa7:c15a:: with SMTP id r26mr3099900edp.264.1632991862038; Thu, 30 Sep 2021 01:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632991862; cv=none; d=google.com; s=arc-20160816; b=t8uVGXLFRftabuLGKgMaC9E+XlCSk/9nt+iE7v1mO3WQMBxwCNBwl/16fjWhZhQnzi giYX7pZZFvjzQ+RsFtaE+5o8aZw+WQhpknbCwaX8TgOLhbMGJ39jg1FNPvt0tW3KpqOj gQ+Ua6di4+UbuvHp/4Fdpf2gnSqzj/BO2CxO3WlwpM5qkU+/TP5V+sFdhIsv+jRgY3KE y1LoZbbxLlPNkkHphSTqXQt6ow4XAiHt4dp/RRnGDvwfauPQydmexybQ49LzlcikqK1L V4yreq4sQDbJtTVMcqasEuqVhV5AQQQD+wZLWMYr/DNcWrxhLqwHG6bKVNHXuKS9ZcZX nn8w== 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=bOGYMdv/BwsOigB/x5GDFYhHCBmuLFqG4tz0Th4S+HE=; b=Btcn8B0Sns+C2Q8YytD2dzkhHSn3SXy2QKz0fC9dJ9KObOrj72aK2VZwsLMB6gPLmU fpBANZAJ0lBQ5fmbhFCSH5lwviGlDBVWGIxwv2yfzaUSEx1MnqRj1+nXJYFS4Iix3DUL kh5RSqy1uwtrm8zCJSQiCBsJfjhDgz4saZqLgkXXAeOo5rrvhVcz09Xh6B3EEYCywxkv Lazi+Kx8GHYuL/tOjBcMBbCqMlpcvYHFaKJogJP6WhGgc6UhiH+xE6euWdp6XQy3qxzJ W34lRd6zh6C6qnplp/tmylaNnyCjJI0jkHTrVN9ms/aSSHdYNmaWfKM2TPdemmSuWQUY Jd/A== 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 h18si2306639eji.692.2021.09.30.01.51.01; Thu, 30 Sep 2021 01:51:02 -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 99BF268A701; Thu, 30 Sep 2021 11:50:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 04DAF68A329 for ; Thu, 30 Sep 2021 11:50:51 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="310684253" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="310684253" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 01:50:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="707804899" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by fmsmga006.fm.intel.com with ESMTP; 30 Sep 2021 01:50:37 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Sep 2021 16:50:22 +0800 Message-Id: <20210930085023.58812-3-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210930085023.58812-1-jianhua.wu@intel.com> References: <20210930085023.58812-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH v4 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: f2Y6uhxIDxJs With the accelerating by means of AVX2, the uyvytoyuv422 can be faster Performance data(Less is better): uyvytoyuv422_sse2 0.50388 uyvytoyuv422_avx 0.46132 uyvytoyuv422_avx2 0.27309 Signed-off-by: Wu Jianhua --- libswscale/x86/rgb2rgb.c | 6 ++++ libswscale/x86/rgb_2_rgb.asm | 60 ++++++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 13 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..1777a99faf 100644 --- a/libswscale/x86/rgb_2_rgb.asm +++ b/libswscale/x86/rgb_2_rgb.asm @@ -31,9 +31,17 @@ 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 +pb_shuffle_low: db 1, 3, 5, 7, 9, 11, 13, 15 +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 +206,16 @@ 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 > 16 + vpbroadcastq m13, [pb_shuffle_low] + movu m15, [pd_permd256_uv] +%endif + .loop_line: mov xq, wq mov wtwoq, wq @@ -246,23 +259,35 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s movu m5, [srcq + wtwoq + mmsize * 3] ; extract y part 1 +%if mmsize < 32 RSHIFT_COPY m6, m2, 1 ; UYVY UYVY -> YVYU YVY... pand m6, m1; YxYx YxYx... RSHIFT_COPY m7, m3, 1 ; UYVY UYVY -> YVYU YVY... pand m7, m1 ; YxYx YxYx... - packuswb m6, m7 ; YYYY YYYY... +%else + pshufb m6, m2, m13 + pshufb m7, m3, m13 + punpcklqdq m6, m6, m7 + VPERM q, 32, m6, m6, 0xd8 +%endif movu [ydstq + wq], m6 ; extract y part 2 +%if mmsize < 32 RSHIFT_COPY m6, m4, 1 ; UYVY UYVY -> YVYU YVY... pand m6, m1; YxYx YxYx... RSHIFT_COPY m7, m5, 1 ; UYVY UYVY -> YVYU YVY... pand m7, m1 ; YxYx YxYx... - - packuswb m6, m7 ; YYYY YYYY... + packuswb m6, m7 ; YYYY YYYY... +%else + pshufb m6, m4, m13 + pshufb m7, m5, m13 + punpcklqdq m6, m6, m7 + VPERM q, 32, m6, m6, 0xd8 +%endif movu [ydstq + wq + mmsize], m6 ; extract uv @@ -275,17 +300,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 +323,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 +345,9 @@ UYVY_TO_YUV422 INIT_XMM avx UYVY_TO_YUV422 + +%if HAVE_AVX2_EXTERNAL +INIT_YMM avx2 +UYVY_TO_YUV422 +%endif %endif From patchwork Thu Sep 30 08:50:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30687 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp441165iob; Thu, 30 Sep 2021 01:51:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9Y0N41CFV8ayf/qhVpT8hn0FkKkivNrhIXL2D7GRnQjGjs7pwFCMonlhYlaZknBOL5dcU X-Received: by 2002:a17:906:8152:: with SMTP id z18mr5454172ejw.153.1632991891608; Thu, 30 Sep 2021 01:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632991891; cv=none; d=google.com; s=arc-20160816; b=qsoSKLL9aIYRKHDOniu0OJ7vqalB+2VD7jfACehMwWfyhFlNa881OUWM9oxfU6VOTR Y+Q5hIf+X/zrOOERFSjNOJP6PmeAKb/D/5M33vwTkQVbNljd8GhcYp+R9S3ZP4YkwUDv PTPcvkimFEz7j3pHF9ZMZdHf2KcggUJVBGEOnYv/1Huq8sUaXDx+LynlwdvvJF320ON7 CjEElCRFfn/DFR7ula1/JuStKfni7JOhN7dH2BpNhmL5C6Ra/7lsY868nyKb3OQBc5/O 7PBS/y8aqZkeZ1PmojCN78GdjlwP8RAPP35I5EKMilbh0M8CfnK5h8DtVe5R4C7j5/SX 1tyQ== 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=ydSJ01I9PpyWktj7bfxeyeEs23IdfPkU/1N+xEAP6wg=; b=A8y0IyjF1fvqWkgeeO8/gt54QpmaqX/Ycd7Oyp8f2SIeDRsegoqrQELZpXCUCsr7o0 7UnTNoFm9cTtq3EHNSmQQyZtzwLpw16nWUr4IfK8EApnPdxAWowSES5EmulgX4WmyYBr f4lrELxdTjZirmcfJoyXMclq/2gB3Su+lWhCCuLTDogJfrXWsX8d539I5YLxID7rjtHQ w7zLuO8m51feyUFBKk5K4mGgjHMUfPANTZzbPVJLzqDyH1iy6uaOi+fSxhyNoDDjtEkn 6LWmQsRKRLJrovM7LubN96AEFXYi0TSlbatyXwtOGLwcz6GbEXXeZnbBFZWOTCUqceGg 9zXQ== 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 m19si2428948edr.573.2021.09.30.01.51.31; Thu, 30 Sep 2021 01:51: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 D631E68A83E; Thu, 30 Sep 2021 11:51:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F189868A306 for ; Thu, 30 Sep 2021 11:51:03 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="310684258" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="310684258" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 01:50:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="707805220" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by fmsmga006.fm.intel.com with ESMTP; 30 Sep 2021 01:50:38 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Sep 2021 16:50:23 +0800 Message-Id: <20210930085023.58812-4-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210930085023.58812-1-jianhua.wu@intel.com> References: <20210930085023.58812-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH v4 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: dLK7QwTkvqpY With the accelerating by means of AVX512, the uyvytoyuv422 can be faster. Performance data(Less is better): uyvytoyuv422_avx2 0.27309 uyvytoyuv422_avx512 0.16229 Signed-off-by: Wu Jianhua --- libswscale/x86/rgb2rgb.c | 6 ++++++ libswscale/x86/rgb_2_rgb.asm | 20 ++++++++++++++++++++ 2 files changed, 26 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 1777a99faf..d55d2ca07f 100644 --- a/libswscale/x86/rgb_2_rgb.asm +++ b/libswscale/x86/rgb_2_rgb.asm @@ -31,8 +31,10 @@ 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 pb_shuffle_low: db 1, 3, 5, 7, 9, 11, 13, 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 @@ -194,7 +196,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 @@ -213,7 +219,12 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s %if mmsize > 16 vpbroadcastq m13, [pb_shuffle_low] +%if mmsize == 32 movu m15, [pd_permd256_uv] +%else + movu m14, [pq_permq512_yy] + movu m15, [pd_permd512_uv] +%endif %endif .loop_line: @@ -271,6 +282,7 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s pshufb m7, m3, m13 punpcklqdq m6, m6, m7 VPERM q, 32, m6, m6, 0xd8 + VPERM q, 64, m6, m14, m6 %endif movu [ydstq + wq], m6 @@ -287,6 +299,7 @@ cglobal uyvytoyuv422, 9, 14, 8, ydst, udst, vdst, src, w, h, lum_stride, chrom_s pshufb m7, m5, m13 punpcklqdq m6, m6, m7 VPERM q, 32, m6, m6, 0xd8 + VPERM q, 64, m6, m14, m6 %endif movu [ydstq + wq + mmsize], m6 @@ -305,6 +318,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 @@ -314,6 +328,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 @@ -350,4 +365,9 @@ UYVY_TO_YUV422 INIT_YMM avx2 UYVY_TO_YUV422 %endif + +%if HAVE_AVX512_EXTERNAL +INIT_ZMM avx512 +UYVY_TO_YUV422 +%endif %endif