[FFmpeg-devel] [PATCH 01/14] swscale/range_convert: call arch-specific init functions from main init function
Ramiro Polla
ramiro.polla at gmail.com
Mon Sep 23 15:40:04 EEST 2024
This commit also fixes the issue that the call to ff_sws_init_range_convert()
from sws_init_swscale() was not setting up the arch-specific optimizations.
---
libswscale/aarch64/swscale.c | 5 ++++-
libswscale/loongarch/swscale_init_loongarch.c | 1 -
libswscale/riscv/swscale.c | 7 ++++---
libswscale/swscale.c | 10 ++++++++++
libswscale/swscale_internal.h | 1 +
libswscale/utils.c | 10 +---------
libswscale/x86/swscale.c | 2 --
7 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c
index eb907284e7..863627d7c3 100644
--- a/libswscale/aarch64/swscale.c
+++ b/libswscale/aarch64/swscale.c
@@ -225,6 +225,9 @@ void ff_chrRangeToJpeg_neon(int16_t *dstU, int16_t *dstV, int width);
av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c)
{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (have_neon(cpu_flags)) {
if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
if (c->dstBpc <= 14) {
if (c->srcRange) {
@@ -236,6 +239,7 @@ av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c)
}
}
}
+ }
}
av_cold void ff_sws_init_swscale_aarch64(SwsContext *c)
@@ -296,6 +300,5 @@ av_cold void ff_sws_init_swscale_aarch64(SwsContext *c)
default:
break;
}
- ff_sws_init_range_convert_aarch64(c);
}
}
diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c
index 2a95ede6d9..88ad21a103 100644
--- a/libswscale/loongarch/swscale_init_loongarch.c
+++ b/libswscale/loongarch/swscale_init_loongarch.c
@@ -95,7 +95,6 @@ av_cold void ff_sws_init_swscale_loongarch(SwsContext *c)
}
}
#endif // #if HAVE_LASX
- ff_sws_init_range_convert_loongarch(c);
}
av_cold void rgb2rgb_init_loongarch(void)
diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c
index c452d93e5d..ad579308c5 100644
--- a/libswscale/riscv/swscale.c
+++ b/libswscale/riscv/swscale.c
@@ -26,9 +26,11 @@ void ff_range_chr_to_jpeg_16_rvv(int16_t *, int16_t *, int);
void ff_range_lum_from_jpeg_16_rvv(int16_t *, int);
void ff_range_chr_from_jpeg_16_rvv(int16_t *, int16_t *, int);
-av_cold static void ff_sws_init_range_convert_riscv(SwsContext *c, int flags)
+av_cold void ff_sws_init_range_convert_riscv(SwsContext *c)
{
#if HAVE_RVV
+ int flags = av_get_cpu_flags();
+
static const struct {
void (*lum)(int16_t *, int);
void (*chr)(int16_t *, int16_t *, int);
@@ -67,9 +69,9 @@ RVV_INPUT(rgba32);
av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
{
+#if HAVE_RVV
int flags = av_get_cpu_flags();
-#if HAVE_RVV
if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
switch (c->srcFormat) {
case AV_PIX_FMT_ABGR:
@@ -122,5 +124,4 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c)
}
}
#endif
- ff_sws_init_range_convert_riscv(c, flags);
}
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 8b6a3a84b4..7f47dab4b6 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -554,6 +554,16 @@ av_cold void ff_sws_init_range_convert(SwsContext *c)
}
}
}
+
+#if ARCH_AARCH64
+ ff_sws_init_range_convert_aarch64(c);
+#elif ARCH_LOONGARCH64
+ ff_sws_init_range_convert_loongarch(c);
+#elif ARCH_RISCV
+ ff_sws_init_range_convert_riscv(c);
+#elif ARCH_X86
+ ff_sws_init_range_convert_x86(c);
+#endif
}
static av_cold void sws_init_swscale(SwsContext *c)
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 50127d288f..66be22ac05 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -697,6 +697,7 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY);
av_cold void ff_sws_init_range_convert(SwsContext *c);
av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c);
av_cold void ff_sws_init_range_convert_loongarch(SwsContext *c);
+av_cold void ff_sws_init_range_convert_riscv(SwsContext *c);
av_cold void ff_sws_init_range_convert_x86(SwsContext *c);
SwsFunc ff_yuv2rgb_init_x86(SwsContext *c);
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c3154d82c1..4dec29ad96 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1078,16 +1078,8 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
c->srcRange = srcRange;
c->dstRange = dstRange;
- if (need_reinit) {
+ if (need_reinit)
ff_sws_init_range_convert(c);
-#if ARCH_AARCH64
- ff_sws_init_range_convert_aarch64(c);
-#elif ARCH_LOONGARCH64
- ff_sws_init_range_convert_loongarch(c);
-#elif ARCH_X86
- ff_sws_init_range_convert_x86(c);
-#endif
- }
c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 43319fd6b2..c82311d87b 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -851,6 +851,4 @@ switch(c->dstBpc){ \
}
#endif
-
- ff_sws_init_range_convert_x86(c);
}
--
2.30.2
More information about the ffmpeg-devel
mailing list