[FFmpeg-devel,1/3] lavu/x86util: make imprecise PMINSD implementation opt-in

Submitted by Rodger Combs on Jan. 23, 2019, 2:39 a.m.

Details

Message ID 20190123023914.20619-1-rodger.combs@gmail.com
State New
Headers show

Commit Message

Rodger Combs Jan. 23, 2019, 2:39 a.m.
This caused rounding errors when values that can't be expressed exactly as
32-bit floats were passed in, which could happen in 16-bit yadif

swscale's call is opted in, under the assumption that it never uses values
large enough to run into this (i.e. within 2^24)
---
 libavutil/x86/x86util.asm | 4 ++--
 libswscale/x86/scale.asm  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavutil/x86/x86util.asm b/libavutil/x86/x86util.asm
index d7cd996842..c96afb6ef1 100644
--- a/libavutil/x86/x86util.asm
+++ b/libavutil/x86/x86util.asm
@@ -799,10 +799,10 @@ 
     pminsw %1, %3
 %endmacro
 
-%macro PMINSD 3 ; dst, src, tmp/unused
+%macro PMINSD 3-4 ; dst, src, tmp/unused, rounding-allowed
 %if cpuflag(sse4)
     pminsd    %1, %2
-%elif cpuflag(sse2)
+%elif cpuflag(sse2) && (%0 > 3)
     cvtdq2ps  %1, %1
     minps     %1, %2
     cvtps2dq  %1, %1
diff --git a/libswscale/x86/scale.asm b/libswscale/x86/scale.asm
index 83cabff722..914fd1ada4 100644
--- a/libswscale/x86/scale.asm
+++ b/libswscale/x86/scale.asm
@@ -364,7 +364,7 @@  cglobal hscale%1to%2_%4, %5, 10, %6, pos0, dst, w, srcmem, filter, fltpos, fltsi
     movd [dstq+wq*2], m0
 %endif ; %3 ==/!= X
 %else ; %2 == 19
-    PMINSD        m0, m2, m4
+    PMINSD        m0, m2, m4, 1
 %ifnidn %3, X
     mova [dstq+wq*(4>>wshr)], m0
 %else ; %3 == X