swscale/range_convert: call arch-specific init functions from main init function

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.
This commit is contained in:
Ramiro Polla 2024-09-18 11:23:18 +02:00
parent 9b0128aa76
commit 7728b3357d
7 changed files with 20 additions and 16 deletions

View File

@ -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);
}
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -851,6 +851,4 @@ switch(c->dstBpc){ \
}
#endif
ff_sws_init_range_convert_x86(c);
}