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,