diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index 5173359e09..1fce77df26 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -225,6 +225,10 @@ void ff_chrRangeToJpeg_neon(int16_t *dstU, int16_t *dstV, int width); av_cold void ff_sws_init_range_convert_aarch64(SwsInternal *c) { + /* This code is currently disabled because of changes in the base + * implementation of these functions. This code should be enabled + * again once those changes are ported to this architecture. */ +#if 0 int cpu_flags = av_get_cpu_flags(); if (have_neon(cpu_flags)) { @@ -238,6 +242,7 @@ av_cold void ff_sws_init_range_convert_aarch64(SwsInternal *c) } } } +#endif } av_cold void ff_sws_init_swscale_aarch64(SwsInternal *c) diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c index 5204a8b66d..f0b8a7db12 100644 --- a/libswscale/loongarch/swscale_init_loongarch.c +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -26,6 +26,10 @@ av_cold void ff_sws_init_range_convert_loongarch(SwsInternal *c) { + /* This code is currently disabled because of changes in the base + * implementation of these functions. This code should be enabled + * again once those changes are ported to this architecture. */ +#if 0 int cpu_flags = av_get_cpu_flags(); if (have_lsx(cpu_flags)) { @@ -52,6 +56,7 @@ av_cold void ff_sws_init_range_convert_loongarch(SwsInternal *c) } } #endif // #if HAVE_LASX +#endif } av_cold void ff_sws_init_swscale_loongarch(SwsInternal *c) diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c index 3bdaf20af4..49c492f153 100644 --- a/libswscale/riscv/swscale.c +++ b/libswscale/riscv/swscale.c @@ -28,6 +28,10 @@ void ff_range_chr_from_jpeg_16_rvv(int16_t *, int16_t *, int); av_cold void ff_sws_init_range_convert_riscv(SwsInternal *c) { + /* This code is currently disabled because of changes in the base + * implementation of these functions. This code should be enabled + * again once those changes are ported to this architecture. */ +#if 0 #if HAVE_RVV int flags = av_get_cpu_flags(); @@ -47,6 +51,7 @@ av_cold void ff_sws_init_range_convert_riscv(SwsInternal *c) c->chrConvertRange = convs[from].chr; } #endif +#endif } #define RVV_INPUT(name) \ diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 3c4637c0a1..9d430920aa 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -160,8 +160,10 @@ static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width) { int i; for (i = 0; i < width; i++) { - dstU[i] = (FFMIN(dstU[i], 30775) * 4663 - 9289992) >> 12; // -264 - dstV[i] = (FFMIN(dstV[i], 30775) * 4663 - 9289992) >> 12; // -264 + int U = (dstU[i] * 4663 - 9289992) >> 12; // -264 + int V = (dstV[i] * 4663 - 9289992) >> 12; // -264 + dstU[i] = FFMIN(U, (1 << 15) - 1); + dstV[i] = FFMIN(V, (1 << 15) - 1); } } @@ -177,8 +179,10 @@ static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width) static void lumRangeToJpeg_c(int16_t *dst, int width) { int i; - for (i = 0; i < width; i++) - dst[i] = (FFMIN(dst[i], 30189) * 19077 - 39057361) >> 14; + for (i = 0; i < width; i++) { + int Y = (dst[i] * 19077 - 39057361) >> 14; + dst[i] = FFMIN(Y, (1 << 15) - 1); + } } static void lumRangeFromJpeg_c(int16_t *dst, int width) @@ -194,8 +198,10 @@ static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width) int32_t *dstU = (int32_t *) _dstU; int32_t *dstV = (int32_t *) _dstV; for (i = 0; i < width; i++) { - dstU[i] = ((int)(FFMIN(dstU[i], 30775 << 4) * 4663U - (9289992 << 4))) >> 12; // -264 - dstV[i] = ((int)(FFMIN(dstV[i], 30775 << 4) * 4663U - (9289992 << 4))) >> 12; // -264 + int U = ((int)(dstU[i] * 4663U - (9289992 << 4))) >> 12; // -264 + int V = ((int)(dstV[i] * 4663U - (9289992 << 4))) >> 12; // -264 + dstU[i] = FFMIN(U, (1 << 19) - 1); + dstV[i] = FFMIN(V, (1 << 19) - 1); } } @@ -215,7 +221,8 @@ static void lumRangeToJpeg16_c(int16_t *_dst, int width) int i; int32_t *dst = (int32_t *) _dst; for (i = 0; i < width; i++) { - dst[i] = ((int)(FFMIN(dst[i], 30189 << 4) * 4769U - (39057361 << 2))) >> 12; + int Y = ((int)(dst[i] * 4769U - (39057361 << 2))) >> 12; + dst[i] = FFMIN(Y, (1 << 19) - 1); } } diff --git a/libswscale/x86/range_convert.asm b/libswscale/x86/range_convert.asm index 97c7525448..ffda009c4e 100644 --- a/libswscale/x86/range_convert.asm +++ b/libswscale/x86/range_convert.asm @@ -40,9 +40,6 @@ lum_from_offset: times 4 dd 33561947 SECTION .text -; NOTE: there is no need to clamp the input when converting to jpeg range -; (like we do in the C code) because packssdw will saturate the output. - ;----------------------------------------------------------------------------- ; lumConvertRange ;