diff mbox series

[FFmpeg-devel] libswscale/x86/yuv2rgb: Add missing EMMS

Message ID AM9P193MB194004554ECF79F43679CFB2AFF92@AM9P193MB1940.EURP193.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel] libswscale/x86/yuv2rgb: Add missing EMMS | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Mario Hros June 5, 2024, 5:35 p.m. UTC
Previous rewrite from inline assembly into nasm (commit e934194) missed the required EMMS instruction to bring the x87 FPU back into usable state.

Signed-off-by: Mario Hros <k3x-devel@outlook.com>
---
 libswscale/x86/yuv_2_rgb.asm | 1 +
 1 file changed, 1 insertion(+)

Comments

Mario Hros June 11, 2024, 5:19 p.m. UTC | #1
Ping?

Not including EMMS causes the FPU to become unusable (as the IE and SF bits are set in the status word). This breaks code which, for instance, calls fmod() and is compiled by GCC with the -O3 flag enabled. In that scenario, GCC implements fmod using the FPREM FPU instruction, but because FPU is in the invalid state at that point, the result is NaN.

This must to breaking other code using FPU also. The original code with inline assembly used EMMS at the end.
diff mbox series

Patch

diff --git a/libswscale/x86/yuv_2_rgb.asm b/libswscale/x86/yuv_2_rgb.asm
index e3470fd9ad..7a247797e4 100644
--- a/libswscale/x86/yuv_2_rgb.asm
+++ b/libswscale/x86/yuv_2_rgb.asm
@@ -353,6 +353,7 @@  cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters
 add imageq, 8 * depth * time_num
 add indexq, 4 * time_num
 js .loop0
+emms
 
 RET