[FFmpeg-devel] [PATCH 38/41] swscale/x86/yuv2rgb: Disable overridden functions on x64
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Fri Jun 10 02:55:20 EEST 2022
x64 always has MMX, MMXEXT, SSE and SSE2 and this means
that some functions for MMX, MMXEXT, SSE and 3dnow are always
overridden by other functions (unless one e.g. explicitly
disables SSE2). This commit therefore disables
some MMX functions that are overridden by MMXEXT
at compile-time for x64.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libswscale/x86/yuv2rgb.c | 13 +++++++------
libswscale/x86/yuv2rgb_template.c | 5 +++--
libswscale/x86/yuv_2_rgb.asm | 5 +++++
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
index 47f45bd7c2..60dcb4b7be 100644
--- a/libswscale/x86/yuv2rgb.c
+++ b/libswscale/x86/yuv2rgb.c
@@ -44,23 +44,22 @@
//MMX versions
#if HAVE_MMX
#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#define COMPILE_TEMPLATE_MMXEXT 0
+#define COMPILE_TEMPLATE_MMX
#define RENAME(a) a ## _mmx
#include "yuv2rgb_template.c"
+#undef COMPILE_TEMPLATE_MMX
#endif /* HAVE_MMX */
// MMXEXT versions
#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#define COMPILE_TEMPLATE_MMXEXT 1
+#define COMPILE_TEMPLATE_MMXEXT
#define RENAME(a) a ## _mmxext
#include "yuv2rgb_template.c"
+#undef COMPILE_TEMPLATE_MMXEXT
//SSSE3 versions
#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#define COMPILE_TEMPLATE_MMXEXT 0
+#define COMPILE_TEMPLATE_SSSE3
#define RENAME(a) a ## _ssse3
#include "yuv2rgb_template.c"
@@ -127,10 +126,12 @@ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
break;
} else
return yuv420_bgr32_mmx;
+#if ARCH_X86_32
case AV_PIX_FMT_RGB24:
return yuv420_rgb24_mmx;
case AV_PIX_FMT_BGR24:
return yuv420_bgr24_mmx;
+#endif
case AV_PIX_FMT_RGB565:
return yuv420_rgb16_mmx;
case AV_PIX_FMT_RGB555:
diff --git a/libswscale/x86/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c
index d506f75e15..b60567b8f6 100644
--- a/libswscale/x86/yuv2rgb_template.c
+++ b/libswscale/x86/yuv2rgb_template.c
@@ -47,7 +47,7 @@ extern void RENAME(ff_yuv_420_bgr24)(x86_reg index, uint8_t *image, const uint8_
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
const uint8_t *py_2index);
-#if !COMPILE_TEMPLATE_MMXEXT
+#ifndef COMPILE_TEMPLATE_MMXEXT
extern void RENAME(ff_yuv_420_rgb15)(x86_reg index, uint8_t *image, const uint8_t *pu_index,
const uint8_t *pv_index, const uint64_t *pointer_c_dither,
const uint8_t *py_2index);
@@ -165,6 +165,7 @@ static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[],
}
#endif
+#if ARCH_X86_32 || !defined(COMPILE_TEMPLATE_MMX)
static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[],
int srcStride[],
int srcSliceY, int srcSliceH,
@@ -192,4 +193,4 @@ static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[],
}
return srcSliceH;
}
-
+#endif
diff --git a/libswscale/x86/yuv_2_rgb.asm b/libswscale/x86/yuv_2_rgb.asm
index f968b3a0a2..542e3cb1ab 100644
--- a/libswscale/x86/yuv_2_rgb.asm
+++ b/libswscale/x86/yuv_2_rgb.asm
@@ -69,6 +69,9 @@ SECTION .text
%ifidn %1, yuva
%define parameters index, image, pu_index, pv_index, pointer_c_dither, py_2index, pa_2index
%define GPR_num 7
+ %else
+ %define parameters index, image, pu_index, pv_index, pointer_c_dither, py_2index
+ %define GPR_num 6
%endif
%else
%define parameters index, image, pu_index, pv_index, pointer_c_dither, py_2index
@@ -356,8 +359,10 @@ REP_RET
%endmacro
INIT_MMX mmx
+%if ARCH_X86_32
yuv2rgb_fn yuv, rgb, 24
yuv2rgb_fn yuv, bgr, 24
+%endif
yuv2rgb_fn yuv, rgb, 32
yuv2rgb_fn yuv, bgr, 32
yuv2rgb_fn yuva, rgb, 32
--
2.34.1
More information about the ffmpeg-devel
mailing list