diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index 4c31b78ed8..20697fc590 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(SwsInternal *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(SwsInternal *c) } } } + } } av_cold void ff_sws_init_swscale_aarch64(SwsInternal *c) @@ -296,6 +300,5 @@ av_cold void ff_sws_init_swscale_aarch64(SwsInternal *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 7cc92be216..0c3a99d167 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(SwsInternal *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 8ed9ce969e..4bc6fb1e6d 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(SwsInternal *c, int flags) +av_cold void ff_sws_init_range_convert_riscv(SwsInternal *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(SwsInternal *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(SwsInternal *c) } } #endif - ff_sws_init_range_convert_riscv(c, flags); } diff --git a/libswscale/swscale.c b/libswscale/swscale.c index e0a9e0279f..3d9b9d4b96 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -563,6 +563,16 @@ av_cold void ff_sws_init_range_convert(SwsInternal *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(SwsInternal *c) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index b8820ea0ba..0035168997 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -719,6 +719,7 @@ void ff_update_palette(SwsInternal *c, const uint32_t *pal); av_cold void ff_sws_init_range_convert(SwsInternal *c); av_cold void ff_sws_init_range_convert_aarch64(SwsInternal *c); av_cold void ff_sws_init_range_convert_loongarch(SwsInternal *c); +av_cold void ff_sws_init_range_convert_riscv(SwsInternal *c); av_cold void ff_sws_init_range_convert_x86(SwsInternal *c); SwsFunc ff_yuv2rgb_init_x86(SwsInternal *c); diff --git a/libswscale/utils.c b/libswscale/utils.c index c49121de59..1c3b4083df 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1095,16 +1095,8 @@ int sws_setColorspaceDetails(SwsContext *sws, 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 16182124c0..28e8c2ad26 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); }