From patchwork Thu Sep 30 01:56:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30672 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp177293iob; Wed, 29 Sep 2021 18:57:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFC3tqEBUD/tUSoWzRBE0H9juAr+V4lOKQwk0egnGanyj2fRWRrfdorD+0lEKwh+FuuIfM X-Received: by 2002:a17:906:7047:: with SMTP id r7mr3666926ejj.342.1632967024698; Wed, 29 Sep 2021 18:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632967024; cv=none; d=google.com; s=arc-20160816; b=z46g9CyvGmT1PCNZHMOwW+6lin5btOWIClTT94oCeapnX9E/QwVgLAeyZB1iNVMSwy +Uj7EbxEkHTJABZ8iXl68zpFfN1y8LMgz+gEYR/DcAUKPr2UvdW/UUZwzBxjuqP6sdoy 4s8aPOPKRfL9ZUK3pJ9RSdZAhvExbftR2qNRpy2Tu1g09ypxM5MDKPfKP5tIk/Rapii5 fZpW19Fh2rtk0/RJMprnW5O+/iJ40MHSq0YK0p8t4Vsf5zW0mAuV8HT4+Q3LMfiNRIRi AgGepbi36scrFAaXTPs8I858xap2RbgSSOURnweXft2lhgf2EUYyQSovGxZHlvGs6IV0 WJeg== 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=MK/Gh9JyINJbMo5yTNBUpRgjrpA/zpfw6VVtO+ofL6A=; b=T5ajwquCapu4k75/X0gI0RRq9hr8CTl+EF0wB10gqrk6710fcQZsrVIYpTLB4jEUkg UUJhHlSCxHBC23OQsyE+U8I3D6U1yMEzxRuO5EoOd7XanV57eZ53LHzGblIg8kj5K7qK p5GC2sEYgPwU7nZgfy9FImXAoBvZ25ENWCQrlsQPY/tf7ECwZRTGQKkX7WK3s5aSLQjm oLDGUYVXh+SKbYaOU3kMyRk3BOD5FyxScNMf0W7fd7kw170mL+zPAGpq4Kep6KrhiUs7 VH/wk3zUzj5mgCrAQbb/ytYdvbekuDzlzKtpLl+pxQspue+mvPw6X4DMZIIYfTN3pbPl daSw== 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 c24si1913778ejj.646.2021.09.29.18.57.04; Wed, 29 Sep 2021 18:57:04 -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 0EBBB68A6EA; Thu, 30 Sep 2021 04:56:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 03E0668A6B6 for ; Thu, 30 Sep 2021 04:56:25 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="247614451" X-IronPort-AV: E=Sophos;i="5.85,334,1624345200"; d="scan'208";a="247614451" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2021 18:56:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,334,1624345200"; d="scan'208";a="563760916" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by fmsmga002.fm.intel.com with ESMTP; 29 Sep 2021 18:56:20 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Sep 2021 09:56:12 +0800 Message-Id: <20210930015612.29608-4-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210930015612.29608-1-jianhua.wu@intel.com> References: <20210930015612.29608-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH v2 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: j+hxJfaJDTHa 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 41ac91a747..b792201df6 100644 --- a/libswscale/x86/rgb_2_rgb.asm +++ b/libswscale/x86/rgb_2_rgb.asm @@ -32,7 +32,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 @@ -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 movu 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