* [FFmpeg-devel] [PATCH 2/3] tests/checkasm: add check for vf_colordetect
2025-07-16 15:25 [FFmpeg-devel] [PATCH 1/3] avfilter/vf_colordetect: add new color range detection filter Niklas Haas
@ 2025-07-16 15:25 ` Niklas Haas
2025-07-16 15:25 ` [FFmpeg-devel] [PATCH 3/3] avfilter/vf_colordetect: add x86 SIMD implementation Niklas Haas
2025-07-16 15:48 ` [FFmpeg-devel] [PATCH 1/3] avfilter/vf_colordetect: add new color range detection filter Niklas Haas
2 siblings, 0 replies; 4+ messages in thread
From: Niklas Haas @ 2025-07-16 15:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
From: Niklas Haas <git@haasn.dev>
---
tests/checkasm/Makefile | 1 +
tests/checkasm/checkasm.c | 3 +
tests/checkasm/checkasm.h | 1 +
tests/checkasm/vf_colordetect.c | 129 ++++++++++++++++++++++++++++++++
4 files changed, 134 insertions(+)
create mode 100644 tests/checkasm/vf_colordetect.c
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index afd62d95ba..d8328ecc68 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -55,6 +55,7 @@ CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes)
AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
AVFILTEROBJS-$(CONFIG_BWDIF_FILTER) += vf_bwdif.o
+AVFILTEROBJS-$(CONFIG_COLORDETECT_FILTER)+= vf_colordetect.o
AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
AVFILTEROBJS-$(CONFIG_EQ_FILTER) += vf_eq.o
AVFILTEROBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index f4e3d4f433..e01994768e 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -269,6 +269,9 @@ static const struct {
#if CONFIG_BWDIF_FILTER
{ "vf_bwdif", checkasm_check_vf_bwdif },
#endif
+ #if CONFIG_COLORDETECT_FILTER
+ { "vf_colordetect", checkasm_check_colordetect },
+ #endif
#if CONFIG_COLORSPACE_FILTER
{ "vf_colorspace", checkasm_check_colorspace },
#endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index e829942d58..0b3e238318 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -89,6 +89,7 @@ void checkasm_check_av_tx(void);
void checkasm_check_blend(void);
void checkasm_check_blockdsp(void);
void checkasm_check_bswapdsp(void);
+void checkasm_check_colordetect(void);
void checkasm_check_colorspace(void);
void checkasm_check_diracdsp(void);
void checkasm_check_exrdsp(void);
diff --git a/tests/checkasm/vf_colordetect.c b/tests/checkasm/vf_colordetect.c
new file mode 100644
index 0000000000..ac505041f6
--- /dev/null
+++ b/tests/checkasm/vf_colordetect.c
@@ -0,0 +1,129 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <string.h>
+#include "checkasm.h"
+
+#include "libavfilter/vf_colordetect.h"
+#include "libavutil/mem_internal.h"
+
+#define WIDTH 256
+#define HEIGHT 16
+#define STRIDE (WIDTH + 32)
+
+static void check_range_detect(int depth)
+{
+ const int mpeg_min = 16 << (depth - 8);
+ const int mpeg_max = 235 << (depth - 8);
+
+ FFColorDetectDSPContext dsp = {0};
+ ff_color_detect_dsp_init(&dsp, depth, AVCOL_RANGE_UNSPECIFIED);
+
+ declare_func(int, const uint8_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t, int, int);
+
+ /* Initialize to 128, which should always return 0 */
+ LOCAL_ALIGNED_32(uint8_t, in, [HEIGHT * STRIDE]);
+ memset(in, 0x80, HEIGHT * STRIDE);
+
+ /* Place an out-of-range value in a random position near the center */
+ const int h2 = HEIGHT >> 1;
+ int idx0 = ((rnd() % h2) + h2) * STRIDE + (rnd() % WIDTH);
+ if (depth > 8) {
+ idx0 &= ~1;
+ in[idx0] = in[idx0 + 1] = 0;
+ } else {
+ in[idx0] = 0;
+ }
+
+ int w = WIDTH;
+ if (depth > 8)
+ w /= 2;
+
+ if (check_func(dsp.detect_range, "rangedetect%d", depth)) {
+ /* Test increasing height, to ensure we hit the placed 0 eventually */
+ for (int h = 1; h <= HEIGHT; h++) {
+ int res_ref = call_ref(in, STRIDE, w, h, mpeg_min, mpeg_max);
+ int res_new = call_new(in, STRIDE, w, h, mpeg_min, mpeg_max);
+ if (res_ref != res_new)
+ fail();
+ }
+
+ /* Test performance of base case without any out-of-range values */
+ memset(in, 0x80, HEIGHT * STRIDE);
+ bench_new(in, STRIDE, w, HEIGHT, mpeg_min, mpeg_max);
+ }
+}
+
+static void check_alpha_detect(int depth, enum AVColorRange range)
+{
+ const int mpeg_min = 16 << (depth - 8);
+ const int mpeg_max = 235 << (depth - 8);
+ const int p = (1 << depth) - 1;
+ const int q = mpeg_max - mpeg_min;
+ const int k = -mpeg_min * p - 128;
+
+ FFColorDetectDSPContext dsp = {0};
+ ff_color_detect_dsp_init(&dsp, depth, range);
+
+ declare_func(int, const uint8_t *, ptrdiff_t, const uint8_t *, ptrdiff_t,
+ ptrdiff_t, ptrdiff_t, int p, int q, int k);
+
+ LOCAL_ALIGNED_32(uint8_t, luma, [HEIGHT * STRIDE]);
+ LOCAL_ALIGNED_32(uint8_t, alpha, [HEIGHT * STRIDE]);
+ /* Try and force overflow */
+ memset(luma, 0xFE, HEIGHT * STRIDE);
+ memset(alpha, 0xFF, HEIGHT * STRIDE);
+
+ /* Place an out-of-range value in a random position near the center */
+ const int h2 = HEIGHT >> 1;
+ int idx0 = ((rnd() % h2) + h2) * STRIDE + (rnd() % WIDTH);
+ if (depth > 8) {
+ idx0 &= ~1;
+ alpha[idx0] = alpha[idx0 + 1] = 0;
+ } else {
+ alpha[idx0] = 0;
+ }
+
+ int w = WIDTH;
+ if (depth > 8)
+ w /= 2;
+
+ if (check_func(dsp.detect_alpha, "alphadetect%d_%s", depth, range == AVCOL_RANGE_JPEG ? "full" : "limited")) {
+ /* Test increasing height, to ensure we hit the placed 0 eventually */
+ for (int h = 1; h <= HEIGHT; h++) {
+ int res_ref = call_ref(luma, STRIDE, alpha, STRIDE, w, h, p, q, k);
+ int res_new = call_new(luma, STRIDE, alpha, STRIDE, w, h, p, q, k);
+ if (res_ref != res_new)
+ fail();
+ }
+
+ /* Test performance of base case without any out-of-range values */
+ memset(alpha, 0xFF, HEIGHT * STRIDE);
+ bench_new(luma, STRIDE, alpha, STRIDE, w, HEIGHT, p, q, k);
+ }
+}
+
+void checkasm_check_colordetect(void)
+{
+ for (int depth = 8; depth <= 16; depth += 8) {
+ check_range_detect(depth);
+ check_alpha_detect(depth, AVCOL_RANGE_JPEG);
+ check_alpha_detect(depth, AVCOL_RANGE_MPEG);
+ report("colordetect%d", depth);
+ }
+}
--
2.50.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 3/3] avfilter/vf_colordetect: add x86 SIMD implementation
2025-07-16 15:25 [FFmpeg-devel] [PATCH 1/3] avfilter/vf_colordetect: add new color range detection filter Niklas Haas
2025-07-16 15:25 ` [FFmpeg-devel] [PATCH 2/3] tests/checkasm: add check for vf_colordetect Niklas Haas
@ 2025-07-16 15:25 ` Niklas Haas
2025-07-16 15:48 ` [FFmpeg-devel] [PATCH 1/3] avfilter/vf_colordetect: add new color range detection filter Niklas Haas
2 siblings, 0 replies; 4+ messages in thread
From: Niklas Haas @ 2025-07-16 15:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
From: Niklas Haas <git@haasn.dev>
alphadetect8_full_c: 6334.7 ( 1.00x)
alphadetect8_full_avx2: 208.1 (30.44x)
alphadetect8_full_avx512: 123.3 (51.39x)
alphadetect8_limited_c: 645.3 ( 1.00x)
alphadetect8_limited_avx2: 47.7 (13.53x)
alphadetect8_limited_avx512: 30.6 (21.05x)
alphadetect16_full_c: 3347.0 ( 1.00x)
alphadetect16_full_avx2: 213.9 (15.65x)
alphadetect16_full_avx512: 132.6 (25.24x)
alphadetect16_limited_c: 306.4 ( 1.00x)
alphadetect16_limited_avx2: 45.0 ( 6.81x)
alphadetect16_limited_avx512: 37.7 ( 8.13x)
rangedetect8_c: 12117.3 ( 1.00x)
rangedetect8_avx2: 188.1 (64.43x)
rangedetect8_avx512: 120.3 (100.73x)
rangedetect16_c: 5603.3 ( 1.00x)
rangedetect16_avx2: 184.3 (30.41x)
rangedetect16_avx512: 130.1 (43.08x)
---
libavfilter/vf_colordetect.c | 4 +
libavfilter/vf_colordetect.h | 3 +
libavfilter/x86/Makefile | 2 +
libavfilter/x86/vf_colordetect.asm | 149 ++++++++++++++++++++++++++
libavfilter/x86/vf_colordetect_init.c | 105 ++++++++++++++++++
5 files changed, 263 insertions(+)
create mode 100644 libavfilter/x86/vf_colordetect.asm
create mode 100644 libavfilter/x86/vf_colordetect_init.c
diff --git a/libavfilter/vf_colordetect.c b/libavfilter/vf_colordetect.c
index 8cb860da3b..641bfbbae3 100644
--- a/libavfilter/vf_colordetect.c
+++ b/libavfilter/vf_colordetect.c
@@ -219,6 +219,10 @@ static av_cold void uninit(AVFilterContext *ctx)
av_cold void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth,
enum AVColorRange color_range)
{
+#if ARCH_X86
+ ff_color_detect_dsp_init_x86(dsp, depth, color_range);
+#endif
+
if (!dsp->detect_range)
dsp->detect_range = depth > 8 ? ff_detect_range16_c : ff_detect_range_c;
if (!dsp->detect_alpha) {
diff --git a/libavfilter/vf_colordetect.h b/libavfilter/vf_colordetect.h
index 16718de38c..c7622ff257 100644
--- a/libavfilter/vf_colordetect.h
+++ b/libavfilter/vf_colordetect.h
@@ -41,6 +41,9 @@ typedef struct FFColorDetectDSPContext {
void ff_color_detect_dsp_init(FFColorDetectDSPContext *dsp, int depth,
enum AVColorRange color_range);
+void ff_color_detect_dsp_init_x86(FFColorDetectDSPContext *dsp, int depth,
+ enum AVColorRange color_range);
+
static inline int ff_detect_range_c(const uint8_t *data, ptrdiff_t stride,
ptrdiff_t width, ptrdiff_t height,
int mpeg_min, int mpeg_max)
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index 0efe3f8d2c..3a7f761ad4 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -5,6 +5,7 @@ OBJS-$(CONFIG_ANLMDN_FILTER) += x86/af_anlmdn_init.o
OBJS-$(CONFIG_ATADENOISE_FILTER) += x86/vf_atadenoise_init.o
OBJS-$(CONFIG_BLEND_FILTER) += x86/vf_blend_init.o
OBJS-$(CONFIG_BWDIF_FILTER) += x86/vf_bwdif_init.o
+OBJS-$(CONFIG_COLORDETECT_FILTER) += x86/vf_colordetect_init.o
OBJS-$(CONFIG_COLORSPACE_FILTER) += x86/colorspacedsp_init.o
OBJS-$(CONFIG_CONVOLUTION_FILTER) += x86/vf_convolution_init.o
OBJS-$(CONFIG_EBUR128_FILTER) += x86/f_ebur128_init.o
@@ -51,6 +52,7 @@ X86ASM-OBJS-$(CONFIG_ANLMDN_FILTER) += x86/af_anlmdn.o
X86ASM-OBJS-$(CONFIG_ATADENOISE_FILTER) += x86/vf_atadenoise.o
X86ASM-OBJS-$(CONFIG_BLEND_FILTER) += x86/vf_blend.o
X86ASM-OBJS-$(CONFIG_BWDIF_FILTER) += x86/vf_bwdif.o
+X86ASM-OBJS-$(CONFIG_COLORDETECT_FILTER) += x86/vf_colordetect.o
X86ASM-OBJS-$(CONFIG_COLORSPACE_FILTER) += x86/colorspacedsp.o
X86ASM-OBJS-$(CONFIG_CONVOLUTION_FILTER) += x86/vf_convolution.o
X86ASM-OBJS-$(CONFIG_EBUR128_FILTER) += x86/f_ebur128.o
diff --git a/libavfilter/x86/vf_colordetect.asm b/libavfilter/x86/vf_colordetect.asm
new file mode 100644
index 0000000000..05f78c729d
--- /dev/null
+++ b/libavfilter/x86/vf_colordetect.asm
@@ -0,0 +1,149 @@
+;*****************************************************************************
+;* x86-optimized functions for blackdetect filter
+;*
+;* Copyright (C) 2025 Niklas Haas
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;*****************************************************************************
+
+%include "libavutil/x86/x86util.asm"
+
+SECTION .text
+
+%macro detect_range_fn 1 ; suffix
+cglobal detect_range%1, 6, 7, 5, data, stride, width, height, mpeg_min, mpeg_max, x
+ movd xm0, mpeg_mind
+ movd xm1, mpeg_maxd
+ vpbroadcast%1 m0, xm0
+ vpbroadcast%1 m1, xm1
+ add dataq, widthq
+ neg widthq
+.lineloop:
+ mova m2, m0
+ mova m3, m1
+ mov xq, widthq
+ .loop:
+ movu m4, [dataq + xq]
+ pminu%1 m2, m4
+ pmaxu%1 m3, m4
+ add xq, mmsize
+ jl .loop
+
+ ; test if the data is out of range
+ pxor m2, m0
+%if cpuflag(avx512)
+ vpternlogq m2, m3, m1, 0xF6 ; m2 |= m3 ^ m1
+ vptestmq k1, m2, m2
+ kortestb k1, k1
+%else
+ pxor m3, m1
+ por m2, m3
+ ptest m2, m2
+%endif
+ jnz .end
+ add dataq, strideq
+ dec heightq
+ jg .lineloop
+.end:
+ setnz al
+ movzx rax, al
+ RET
+%endmacro
+
+%macro detect_alpha_fn 3 ; suffix, hsuffix, range
+cglobal detect_alpha%1_%3, 6, 7, 6, color, color_stride, alpha, alpha_stride, width, height, x
+ pxor m0, m0
+ add colorq, widthq
+ add alphaq, widthq
+ neg widthq
+%ifidn %3, limited
+%if ARCH_X86_64
+ movq xm3, r6mp ; p
+ movq xm4, r7mp ; q
+ movq xm5, r8mp ; k
+%else
+ movd xm3, r6mp ; p
+ movd xm4, r7mp ; q
+ movd xm5, r8mp ; k
+%endif
+ vpbroadcast%2 m3, xm3
+ vpbroadcast%2 m4, xm4
+ vpbroadcast%2 m5, xm5
+%endif
+.lineloop:
+ mov xq, widthq
+ .loop:
+ %ifidn %3, full
+ movu m1, [colorq + xq]
+ movu m2, [alphaq + xq]
+ pmaxu%1 m1, m2
+ %else
+ pmovzx%1%2 m1, [colorq + xq]
+ pmovzx%1%2 m2, [alphaq + xq]
+ pmull%2 m1, m3
+ pmull%2 m2, m4
+ padd%2 m1, m5
+ pmaxu%2 m1, m2
+ %endif
+ %if cpuflag(avx512)
+ vpternlogq m0, m1, m2, 0xF6 ; m0 |= m1 ^ m2
+ %else
+ pxor m1, m2
+ por m0, m1
+ %endif
+ %ifidn %3, full
+ add xq, mmsize
+ %else
+ add xq, mmsize >> 1
+ %endif
+ jl .loop
+
+%if cpuflag(avx512)
+ vptestmq k1, m0, m0
+ kortestb k1, k1
+%else
+ ptest m0, m0
+%endif
+ jnz .found
+
+ add colorq, color_strideq
+ add alphaq, alpha_strideq
+ dec heightq
+ jg .lineloop
+ xor rax, rax
+ RET
+
+.found:
+ mov rax, 1
+ RET
+%endmacro
+
+INIT_YMM avx2
+detect_range_fn b
+detect_range_fn w
+detect_alpha_fn b, w, full
+detect_alpha_fn w, d, full
+detect_alpha_fn b, w, limited
+detect_alpha_fn w, d, limited
+
+INIT_ZMM avx512
+detect_range_fn b
+detect_range_fn w
+detect_alpha_fn b, w, full
+detect_alpha_fn w, d, full
+detect_alpha_fn b, w, limited
+detect_alpha_fn w, d, limited
diff --git a/libavfilter/x86/vf_colordetect_init.c b/libavfilter/x86/vf_colordetect_init.c
new file mode 100644
index 0000000000..62a7e87388
--- /dev/null
+++ b/libavfilter/x86/vf_colordetect_init.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2025 Niklas Haas
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/attributes.h"
+#include "libavutil/x86/cpu.h"
+#include "libavfilter/vf_colordetect.h"
+
+#define DETECT_RANGE_FUNC(FUNC_NAME, ASM_FUNC_NAME, C_FUNC_NAME, SHIFT, MMSIZE) \
+int ASM_FUNC_NAME(const uint8_t *src, ptrdiff_t stride, \
+ ptrdiff_t width, ptrdiff_t height, int min, int max); \
+ \
+static int FUNC_NAME(const uint8_t *src, ptrdiff_t stride, \
+ ptrdiff_t width, ptrdiff_t height, int min, int max) \
+{ \
+ ptrdiff_t bytes = (width << SHIFT) & ~(MMSIZE - 1); \
+ int ret = ASM_FUNC_NAME(src, stride, bytes, height, min, max); \
+ if (ret) \
+ return ret; \
+ \
+ return C_FUNC_NAME(src + bytes, stride, width - (bytes >> SHIFT), \
+ height, min, max); \
+}
+
+#define DETECT_ALPHA_FUNC(FUNC_NAME, ASM_FUNC_NAME, C_FUNC_NAME, SHIFT, MMSIZE) \
+int ASM_FUNC_NAME(const uint8_t *color, ptrdiff_t color_stride, \
+ const uint8_t *alpha, ptrdiff_t alpha_stride, \
+ ptrdiff_t width, ptrdiff_t height, int p, int q, int k); \
+ \
+static int FUNC_NAME(const uint8_t *color, ptrdiff_t color_stride, \
+ const uint8_t *alpha, ptrdiff_t alpha_stride, \
+ ptrdiff_t width, ptrdiff_t height, int p, int q, int k) \
+{ \
+ ptrdiff_t bytes = (width << SHIFT) & ~(MMSIZE - 1); \
+ int ret = ASM_FUNC_NAME(color, color_stride, alpha, alpha_stride, \
+ bytes, height, p, q, k); \
+ if (ret) \
+ return ret; \
+ \
+ return C_FUNC_NAME(color + bytes, color_stride, alpha + bytes, alpha_stride,\
+ width - (bytes >> SHIFT), height, p, q, k); \
+}
+
+#if HAVE_X86ASM
+#if HAVE_AVX512_EXTERNAL
+DETECT_RANGE_FUNC(detect_range_avx512, ff_detect_rangeb_avx512, ff_detect_range_c, 0, 64)
+DETECT_RANGE_FUNC(detect_range16_avx512, ff_detect_rangew_avx512, ff_detect_range16_c, 1, 64)
+DETECT_ALPHA_FUNC(detect_alpha_full_avx512, ff_detect_alphab_full_avx512, ff_detect_alpha_full_c, 0, 64)
+DETECT_ALPHA_FUNC(detect_alpha16_full_avx512, ff_detect_alphaw_full_avx512, ff_detect_alpha16_full_c, 1, 64)
+DETECT_ALPHA_FUNC(detect_alpha_limited_avx512, ff_detect_alphab_limited_avx512, ff_detect_alpha_limited_c, 0, 64)
+DETECT_ALPHA_FUNC(detect_alpha16_limited_avx512, ff_detect_alphaw_limited_avx512, ff_detect_alpha16_limited_c, 1, 64)
+#endif
+#if HAVE_AVX2_EXTERNAL
+DETECT_RANGE_FUNC(detect_range_avx2, ff_detect_rangeb_avx2, ff_detect_range_c, 0, 32)
+DETECT_RANGE_FUNC(detect_range16_avx2, ff_detect_rangew_avx2, ff_detect_range16_c, 1, 32)
+DETECT_ALPHA_FUNC(detect_alpha_full_avx2, ff_detect_alphab_full_avx2, ff_detect_alpha_full_c, 0, 32)
+DETECT_ALPHA_FUNC(detect_alpha16_full_avx2, ff_detect_alphaw_full_avx2, ff_detect_alpha16_full_c, 1, 32)
+DETECT_ALPHA_FUNC(detect_alpha_limited_avx2, ff_detect_alphab_limited_avx2, ff_detect_alpha_limited_c, 0, 32)
+DETECT_ALPHA_FUNC(detect_alpha16_limited_avx2, ff_detect_alphaw_limited_avx2, ff_detect_alpha16_limited_c, 1, 32)
+#endif
+#endif
+
+av_cold void ff_color_detect_dsp_init_x86(FFColorDetectDSPContext *dsp, int depth,
+ enum AVColorRange color_range)
+{
+#if HAVE_X86ASM
+ int cpu_flags = av_get_cpu_flags();
+#if HAVE_AVX2_EXTERNAL
+ if (EXTERNAL_AVX2(cpu_flags)) {
+ dsp->detect_range = depth > 8 ? detect_range16_avx2 : detect_range_avx2;
+ if (color_range == AVCOL_RANGE_JPEG) {
+ dsp->detect_alpha = depth > 8 ? detect_alpha16_full_avx2 : detect_alpha_full_avx2;
+ } else {
+ dsp->detect_alpha = depth > 8 ? detect_alpha16_limited_avx2 : detect_alpha_limited_avx2;
+ }
+ }
+#endif
+#if HAVE_AVX512_EXTERNAL
+ if (EXTERNAL_AVX512(cpu_flags)) {
+ dsp->detect_range = depth > 8 ? detect_range16_avx512 : detect_range_avx512;
+ if (color_range == AVCOL_RANGE_JPEG) {
+ dsp->detect_alpha = depth > 8 ? detect_alpha16_full_avx512 : detect_alpha_full_avx512;
+ } else {
+ dsp->detect_alpha = depth > 8 ? detect_alpha16_limited_avx512 : detect_alpha_limited_avx512;
+ }
+ }
+#endif
+#endif
+}
--
2.50.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread