From patchwork Thu Sep 30 08:43:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 30684 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp436430iob; Thu, 30 Sep 2021 01:44:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDq2YN7pAk+g1g/AUK5PBd1lFv96MFBl1+NXdoAyOKwLQiZTArtesbdPOly0KGB42N3GHn X-Received: by 2002:a17:906:6691:: with SMTP id z17mr5342752ejo.207.1632991459241; Thu, 30 Sep 2021 01:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632991459; cv=none; d=google.com; s=arc-20160816; b=FOTjILh3FGSBjoE1xnc1eotEBkmwtUy3liz6tDJE2t7a/8B6X9CdFHWXaNZF3h1crl g64I/m3N0eOhUrtPE9IUknuG/e7jMrv16WogKG62R+NKYAJ70khk8/ZBIS3GVUafb7o9 wFEBasHRjSQ+bW0xAfrtEl89sSOKZpON/fog0J6e2d3d1VyxGBfLMOtUbJhV+E4I7G3E fx3GmuhQm6i5sh0ePuPwEtmQGEzQN/crGUPJ20Vlb85fUgMhi5jsZ3VREipyt6BH2XnR 4HnEsGChRjdZZD5h7KskKzMz66OZH4p74AKWYhgBp4GBoHNwvzhCGX0O6p99Ks1Hpfke sBrQ== 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=o+1lGIW3dZLcNYELuXIagLfiMOC6WIGhyBjP1iFDZZJCIUCabHhEghoiIsRfXDwgNr bS3M5KWO3QJT9ki1girxJEGGnwF0+L5jlDRJN4RBAuyBzctJfbKcJn3qQU3QjgjUKGmn z566nXJ9dFDE08E+STNR/Aa6BXHv9yEOugZATa4O7SzoNJ7j6p8BrmCg2hEhSqN29I5b +D40Vgi5VUwsToBGrqG/7z0Vmw4cD/1zhMLqbF/fa0FYnlpIzGAb0J2jDom6O6kvAAc/ EZ8ZLHIlSxd7+A30GmUJB3MhewgmpjIUUcESdEoBXBNHjQm6VqC0lc5Gju65KdGsdM9T xXIg== 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 n3si2482192edd.109.2021.09.30.01.44.18; Thu, 30 Sep 2021 01:44:19 -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 5FFC46899A7; Thu, 30 Sep 2021 11:44:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CA26680610 for ; Thu, 30 Sep 2021 11:44:06 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="224793897" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="224793897" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 01:43:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="563956836" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by fmsmga002.fm.intel.com with ESMTP; 30 Sep 2021 01:43:58 -0700 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Sep 2021 16:43:52 +0800 Message-Id: <20210930084355.76628-1-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH v3 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: OU1s573pZpKQ 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,