[FFmpeg-devel] [PATCH v3 2/4] libswscale/x86/rgb2rgb: add shuffle_bytes avx512

Wu Jianhua jianhua.wu at intel.com
Thu Sep 30 11:43:53 EEST 2021


Performance data(Less is better):
    shuffle_bytes_avx2      0.94288
    shuffle_bytes_avx512    0.60049

Signed-off-by: Wu Jianhua <jianhua.wu at intel.com>
---
 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
 
 ;-----------------------------------------------------------------------------------------------
-- 
2.17.1



More information about the ffmpeg-devel mailing list