---
 libavresample/x86/dither.asm    |   25 +++++++++++++++++++++++++
 libavresample/x86/dither_init.c |   10 ++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/libavresample/x86/dither.asm b/libavresample/x86/dither.asm
index 821a9ef..f914255 100644
--- a/libavresample/x86/dither.asm
+++ b/libavresample/x86/dither.asm
@@ -77,3 +77,28 @@ INIT_XMM fma4
 QUANTIZE_INT rectangular
 QUANTIZE_INT triangular
 %endif
+
+;------------------------------------------------------------------------------
+; void ff_quantize_float(int16_t *dst, float *src, float *dither, int len);
+;------------------------------------------------------------------------------
+
+INIT_XMM sse2
+cglobal quantize_float, 4,4,3, dst, src, dither, len
+    lea         lenq, [2*lend]
+    add         dstq, lenq
+    lea         srcq, [srcq+2*lenq]
+    lea      ditherq, [ditherq+2*lenq]
+    neg         lenq
+    mova          m2, [pf_s16_scale]
+.loop:
+    mulps         m0, m2, [srcq+2*lenq]
+    mulps         m1, m2, [srcq+2*lenq+mmsize]
+    addps         m0, [ditherq+2*lenq]
+    addps         m1, [ditherq+2*lenq+mmsize]
+    cvtps2dq      m0, m0
+    cvtps2dq      m1, m1
+    packssdw      m0, m1
+    mova     [dstq+lenq], m0
+    add         lenq, mmsize
+    jl .loop
+    REP_RET
diff --git a/libavresample/x86/dither_init.c b/libavresample/x86/dither_init.c
index 35a74a0..998e21c 100644
--- a/libavresample/x86/dither_init.c
+++ b/libavresample/x86/dither_init.c
@@ -33,6 +33,9 @@ extern void ff_quantize_int_triangular_sse2(int16_t *dst, 
const float *src,
 extern void ff_quantize_int_triangular_fma4(int16_t *dst, const float *src,
                                             void *dither, int len);
 
+extern void ff_quantize_float_sse2(int16_t *dst, const float *src, void 
*dither,
+                                   int len);
+
 av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
                                 enum AVResampleDitherMethod method)
 {
@@ -63,5 +66,12 @@ av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
             ddsp->samples_align = 8;
         }
         break;
+    case AV_RESAMPLE_DITHER_TRIANGULAR_HP:
+        if (EXTERNAL_SSE2(mm_flags)) {
+            ddsp->quantize      = ff_quantize_float_sse2;
+            ddsp->ptr_align     = 16;
+            ddsp->samples_align = 8;
+        }
+        break;
     }
 }
-- 
1.7.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to