diff mbox series

[FFmpeg-devel,2/2] libswscale: Test AV_CPU_FLAG_SLOW_GATHER for hscale functions.

Message ID 20211220144545.739340-1-alankelly@google.com
State Accepted
Commit eebe406c808e6061ee76e93a616537b5369dbf40
Headers show
Series [FFmpeg-devel,1/2] libavutil/cpu: Add AV_CPU_FLAG_SLOW_GATHER. | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Alan Kelly Dec. 20, 2021, 2:45 p.m. UTC
This is instead of EXTERNAL_AVX2_FAST so that the avx2 hscale functions
are only used where they are faster.
---
 Whoops! Corrects check so that this flag is only enabled where fast
 avx2 and fast gathers are available.
 libswscale/utils.c        | 2 +-
 libswscale/x86/swscale.c  | 2 +-
 tests/checkasm/sw_scale.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libswscale/utils.c b/libswscale/utils.c
index d4a72d3ce1..7158384f0b 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -282,7 +282,7 @@  void ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int filterSiz
 #if ARCH_X86_64
     int i, j, k, l;
     int cpu_flags = av_get_cpu_flags();
-    if (EXTERNAL_AVX2_FAST(cpu_flags)){
+    if (EXTERNAL_AVX2_FAST(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_SLOW_GATHER)) {
         if ((c->srcBpc == 8) && (c->dstBpc <= 14)){
             if (dstW % 16 == 0){
                 if (filter != NULL){
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index c49a05c37b..ffc7691c12 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -578,7 +578,7 @@  switch(c->dstBpc){ \
              break; \
     }
 
-    if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+    if (EXTERNAL_AVX2_FAST(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_SLOW_GATHER)) {
         if ((c->srcBpc == 8) && (c->dstBpc <= 14)) {
             if (c->chrDstW % 16 == 0)
                 ASSIGN_AVX2_SCALE_FUNC(c->hcScale, c->hChrFilterSize);
diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index f4912e6c2c..3c0a083b42 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -217,7 +217,7 @@  static void check_hscale(void)
             }
             ff_sws_init_scale(ctx);
             memcpy(filterAvx2, filter, sizeof(uint16_t) * (SRC_PIXELS * MAX_FILTER_WIDTH + MAX_FILTER_WIDTH));
-            if (cpu_flags & AV_CPU_FLAG_AVX2)
+            if ((cpu_flags & AV_CPU_FLAG_AVX2) && !(cpu_flags & AV_CPU_FLAG_SLOW_GATHER))
                 ff_shuffle_filter_coefficients(ctx, filterPosAvx, width, filterAvx2, SRC_PIXELS);
 
             if (check_func(ctx->hcScale, "hscale_%d_to_%d_width%d", ctx->srcBpc, ctx->dstBpc + 1, width)) {